Parser Combinators(t3.at)
248 points by schindlabua 7 days ago | 88 comments
tl;dr: Parser combinators model parsers as functions of type `(input: string) => [T, string]`, returning a parsed value plus the remaining unconsumed input. Small primitive parsers (like `pInteger`, `pHello`, `pIgnoreWhitespace`) can be composed with higher-order combinators like `pSeq` and `pMap` to build complex parsers—for example, turning raw `ping` output into a structured object. The approach is essentially the inverse of a fold: where reduce collapses a list into a value, parsing unfolds a string into structured data.
HN Discussion:
  • ↑Praises the visual/animated presentation making parser combinators easy to understand
  • ~Criticizes the website's UI/layout for being hard to read, navigate, and search
  • ~Suggests missed opportunities to demonstrate more powerful parsing examples like key-value pairs or alternatives
  • ↓Challenges the article's foundational type signature and 'partial parser' framing as technically incorrect
  • •Shares related tools, poems, or alternative approaches without directly judging the article