argumentcomputer / argumentcomputer/Megaparsec.lean

Improvement: Add a `debug` combinator

Open
#26 1 comment 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
Lean
Stars
37
Forks
8
PR merge metrics
No merged PRs in 30d

Description

# 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`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading Common.lean and inspect the existing parser combinators and tracing usage. Add the requested debug combinator there so parser values can be traced without an inline monadic bind, then verify it against the project’s existing checks.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.