4 ms·
Megaparsec Tutorial
- richardjam73 3y ago[flagged]
- kqr 3y agoStarting with Megaparsec can be a little intimidating. I always encourage new users to start with the built-in ReadP instead. I even wrote an appreciated beginner tutorial on ReadP and parser combinators more generally: https://two-wrongs.com/parser-combinators-parsing-for-haskell-beginners.html https://two-wrongs.com/parser-combinators-parsing-for-haskel...
- fireflies_ 3y agoThanks for sharing. I've used megaparsec a little but never looked at ReadP. Your tutorial is concise and helpful, I'd have ended up with better intuition faster if I started there.
- lgas 3y agoI happened write a parser for a binary protocol using attoparsec before ever trying megaparsec and I found it to be a nice stepping stone.
- whateveracct 3y agoattoparsec is a nice, tight library. It's a true classic.
- platz 3y agowhat considerations are the between choosing parser combinators and using a parser generator?
- solomonb 3y agoCombinators are great for little ad-hoc parsers but if you have gotten to the point of laying out a formal grammar you should go with a parser generator.
- massysett 3y agoThe generator requires that you specify a grammar; combinators don’t. Because the generator has your grammar, it can analyze it and tell you if it’s ambiguous. Combinators can’t. Combinators easily support arbitrary lookahead. The combinator libraries I’ve seen in Haskell can provide excellent error messages while parsing, especially if you spend time tweaking them. The generators I’ve seen don’t have error messages as good. Typically with a generator you use a separate lexer, though I suppose you don’t have to. With combinators, you can use a separate lexer, but this is not typical. Generators require you to run a separate tool to generate the parser and maybe the lexer as well. With combinators you just write them in the host language. This impacts your debugging experience.
- johnnylambada 3y agoI thought this was going to be an article about measuring vast distances in space. Instead it's a tutorial abouta Haskell library. Personally, I was disappointed.
- araes 3y agoExcellent. Similar. Now I want to write an article about Galaxy Clusters and the nigh incomprehensible space between them. You are here -> . You are tiny. [1] https://en.wikipedia.org/wiki/Galaxy_cluster https://en.wikipedia.org/wiki/Galaxy_cluster