jfmengels/elm-review-simplify

Simplifications for Parser

Open

#288 opened on Feb 20, 2024

View on GitHub
 (16 comments) (0 reactions) (0 assignees)Elm (10 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (22 stars)
PR merge metrics
 (PR metrics pending)

Description

  • Parser.map simplifications
  • Parser.andThen simplifications
  • Parser.succeed () |. p -> p
    • Only if p is a Parser ()
    • For styling purposes, should only be done when there is only a single pipe in the expression, and is at the beginning of the chain
  • Parser.succeed identity |= p -> p
    • Same styling requirements as above
  • [ ] Parser.succeed x |. Parser.succeed y -> Parser.succeed x
  • [ ] Parser.succeed always |= p |= q -> Parser.succeed identity |. p |= q
  • Parser.succeed (\_ y -> x) |= p -> Parser.succeed (\y -> x) |. p (Note, may need import of the |. operator)
  • Parser.chompIf (always False) -> Parser.succeed ()
  • Parser.chompWhile (always False) -> Parser.succeed ()
  • Parser.mapChompedString (always f) p -> Parser.map f p
  • Parser.getChompedString (Parser.succeed x) -> Parser.succeed ""

As far as I can tell, all of these would also apply to Parser.Advanced.

Contributor guide