IMHO, MegaParsec has a terrible roadblock for a Haskell beginner. The first thing you’ll try to do with it will be something like (if you’re lucky enough to get the imports right):
import Text.Megaparsec
import Text.Megaparsec.Char.Lexer
main = parseTest decimal "123"
Then you’ll immediately be greeted by a compiler error:
error:
• Ambiguous type variable ‘e0’ arising from a use of ‘parseTest’
prevents the constraint ‘(ShowErrorComponent
e0)’ from being solved.
For a Haskell beginner, it would be almost impossible to guess what to do next. Well, I’ll give spoilers here:
...
import Data.Void
type Parser = Parsec Void String
main = parseTest (decimal :: Parser Integer) "123"
Normally, you’d rely on tutorials around the net to get you covered, but megaparsec had a recent major release which broke all the tutorials you get by googling “Megaparsec getting started”.
Nice share thank you. I want to get started already! And rewrite our main API ;)
The parser was my favorite. I could be misreading it since I dont know the language. The time example did look really easy to express and/or follow.
It is indeed a nice design.
You can read more about Parsec in this paper: https://web.archive.org/web/20140528151730/http://legacy.cs.uu.nl/daan/download/parsec/parsec.pdf
If you plan to give a try, you should directly start with MegaParsec: https://hackage.haskell.org/package/megaparsec
IMHO, MegaParsec has a terrible roadblock for a Haskell beginner. The first thing you’ll try to do with it will be something like (if you’re lucky enough to get the imports right):
Then you’ll immediately be greeted by a compiler error:
For a Haskell beginner, it would be almost impossible to guess what to do next. Well, I’ll give spoilers here:
Normally, you’d rely on tutorials around the net to get you covered, but megaparsec had a recent major release which broke all the tutorials you get by googling “Megaparsec getting started”.
Indeed!