[Haskell-cafe] Parsec question

Thomas Conway drtomc at gmail.com
Thu Jun 21 18:13:42 EDT 2007

On 6/21/07, Jules Bean <jules at jellybean.co.uk> wrote:
> I would write
> primary = PrimaryIdentifier `fmap` identifer
>        <|> PrimaryLiteral    `fmap` stringLiteral
> (I prefer fmap to liftM but they are the same for monads). To my mind
> this fits the general pattern of 'constructor comes before contents'.
> with is, of course, just fmap with the parameters reversed.

Nice. I only discovered the joys of Data.Monad, fmap included
relatively recently, well after I'd spent quite some time writing
parsec parsers.

I note that it was Parsec that converted me to Haskell from Mercury[*]
- I wrote a library of parser combinators for Mercury, but the lambda
notation in Mercury is not nearly so clean as Haskell's, so lacking
special syntax for monadic code, the results looked horrible. Much
faster - Mercury is a strict language, so it's easier to compile into
respectable machine code - but horrible to read.

[*] Well, that, and the fact that my thesis was about Mercury, which
meant that once I was finished, I never wanted to look at Mercury
again. ;-)
Dr Thomas Conway
drtomc at gmail.com

Silence is the perfectest herald of joy:
I were but little happy, if I could say how much.

More information about the Haskell-Cafe mailing list