1. 24

  2. 3

    Nice share thank you. I want to get started already! And rewrite our main API ;)

    1. 3

      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.

      1. 2

        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

        1. 2

          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:

              • 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”.

        2. 1