mrkkrp / mrkkrp/parser-combinators

[Proposal] Adding (back ?) chainl

Open
#62 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
Haskell
Stars
55
Forks
17
PR merge metrics
No merged PRs in 30d

Description

Hi !

Is it possible to add the chainl, chainl1, chainr, chainr1 combinators ? Although Control.Monad.Combinators.Expr does exists, it feels overkill to use when there's only one layer to the chain; and I don't really understand why it was removed from megaparsec

The implementation would be pretty straightforward :

chainl1 parser op = parser >>= rest
  where rest x = do { f <- op; y <- parser; rest (f x y) } <|> return x

chainl parser op x = chainl1 parser op <|> return x

and so on...

Thanks in advance :) !

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the package's existing exports and parser-combinator conventions, then compare the requested chainl, chainl1, chainr, and chainr1 combinators with the implementation shown in the issue. Done means the requested combinators are added consistently to the package and their behavior is covered by the project's existing checks.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.