Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: Add a debug combinator #26

Open
1 task
cognivore opened this issue Sep 7, 2022 · 1 comment
Open
1 task

Improvement: Add a debug combinator #26

cognivore opened this issue Sep 7, 2022 · 1 comment
Labels
good first issue Good for newcomers

Comments

@cognivore
Copy link
Contributor

Why?

While debugging combinatorial parsers, people often wrap a parser into debug like so:

def laLexer : Parsec Char String Unit String :=
  s.lookAhead ((s.stringP "|" <* (void c.eol <|> c.eof)) <|> s.stringP " ")

becomes

def laLexer : Parsec Char String Unit String :=
  s.lookAhead ((s.stringP "|" <* (void (c.eol >>= fun x => do
                                                     dbg_trace! x
                                                     pure x)
                                        <|> c.eof)) <|> s.stringP " ")

It's error-prone. We'd rather have this monadic bind with a trace in a separate combinator!

How?

  • Write such combinator in Common.lean.
@cognivore cognivore added the good first issue Good for newcomers label Sep 7, 2022
@cognivore
Copy link
Contributor Author

Everyone who uses parsec to parse big stuff, would be very happy if this combinator was a thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant