[Haskell-beginners] functional parser type error
felipe zapata
tifonzafel at gmail.com
Mon Apr 2 22:58:31 CEST 2012
Hi.
I'm Following the book of Programming in haskell written by Graham Hutton.
In Chapter number 8 there is a discussion about functional parsers and it
is defined a functional Parser item and some basic parsers as follow
*success :: a -> Parser a*
*success v = \ inp -> [(v,inp)]*
*failure :: Parser a*
*failure = \inp -> [ ]*
*item :: Parser Char*
*item = \inp -> case inp of*
*[ ] -> [ ]*
*(x:xs) -> [(x,xs)]*
Based on this parser it is defined a* *new parser called *sat p*
*sat :: (Char -> Bool ) -> Parser Char*
*sat p = do x <- item*
*if p x then success x else failure*
as result, this error appears
*Couldn't match expected type `Char'*
*with actual type `[(Char, String)]'*
*In the first argument of `p', namely `x'*
*In the expression: p x*
*In the expression: if p x then success x else failure*
Can you help me ?
Greets,
Felipe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120402/332803c2/attachment.htm>
More information about the Beginners
mailing list