[Haskell-cafe] Parsec question
ckkashyap at gmail.com
Wed Jul 24 17:38:53 CEST 2013
There is reference in the paper that empty list indicates failure...so
could we just use it like Maybe? I'd like it very much if I could get
an example of a missed match by not using the complete match.
Sent from my Windows Phone
From: Roman Cheplyaka
Sent: 24/07/2013 8:19 PM
To: C K Kashyap
Cc: Haskell Cafe
Subject: Re: [Haskell-cafe] Parsec question
Think about this: if you always take only the first element, why do you
need lists at all?
* C K Kashyap <ckkashyap at gmail.com> [2013-07-24 19:56:29+0530]
> Dear Cafe,
> I am trying to implement parsec in go using the "Monadic Parser
> Combinators" paper  . I've been able to implement "plus" "bind" and
> While doing the implementation - I looked at bind closely
> bind :: Parser a -> (a -> Parser b) -> Parser b
> p `bind` f = \inp -> concat [f v inp' | (v,inp') <- p inp]
> I wondered if the result needs the complete list - wouldn't just the first
> successful value suffice?
> Perhaps -
> p `bind` f = \inp -> take 1 $ concat [f v inp' | (v,inp') <- p inp]
> Will this miss out matches?
>  https://github.com/ckkashyap/parsec/blob/master/parsec.go
>  Monadic Parser Combinators: Graham Hutton, Erik Meijer
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe