[Haskell-cafe] Parsec question
roma at ro-che.info
Wed Jul 24 16:49:24 CEST 2013
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