[Haskell-cafe] Parsec question
C K Kashyap
ckkashyap at gmail.com
Wed Jul 24 16:26:29 CEST 2013
Dear Cafe,
I am trying to implement[1] parsec in go using the "Monadic Parser
Combinators" paper [2] . I've been able to implement "plus" "bind" and
"many"
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?
Regards,
Kashyap
[1] https://github.com/ckkashyap/parsec/blob/master/parsec.go
[2] Monadic Parser Combinators: Graham Hutton, Erik Meijer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130724/7d3969e7/attachment.htm>
More information about the Haskell-Cafe
mailing list