[Haskell-cafe] Re: Parsec beginners problem
Al Falloon
afalloon at synopsys.com
Fri Apr 27 12:58:15 EDT 2007
Jim Burton wrote:
> After posting I realised the difference between parsing "(a)" <|> "(b)" and
> parsing "a" <|> "aa" ... so Parsec doesn't do the latter well or at all?
It should do (try "aa") <|> "a" just fine. If you mean a general
sequence of "a"s then (many1 (char "a")) should do.
The Morse Code problem is a little harder though. To handle the
ambiguity you may need to simultaneously consider possible parses of the
dots and dashes. I suggest you look into using the List monad. As for
the actual parsing of the dots and dashes, Parsec may be overkill.
More information about the Haskell-Cafe
mailing list