[Haskell-beginners] about parser question < Programming in haskell _ chapter 8 >
anyzhen
jiangzhen3s at qq.com
Mon Jul 18 11:20:28 CEST 2011
well,i am reading the book :<Programming in haskell >
chapter 8 functional parsers
this chapter try teaching an parser technology,but i have some problem about do keyword
--some brief info of types :
type Parser a = String -> [(a,String)]
item :: Parser Char --item "abc" = [('a',"bc")]
return' :: a -> Parser a --return' 'a' "foo" = [('a',"foo")]
--below code complier notice... sorry format
p2 :: Parser (Char,Char)
p2 = do x <- item
item
y <- item
return' (x,y)
"No instance for (Monad ((-)) String))
arising from a execute statement
Possible fix : add an instance declaration for (Monad ((-)) String))
In a stmt of a 'do' expression : y <- item
In the expression:
do { x <- item; item;
y <- item;
return' (x,y)}
In an equation for 'p2':
p2
= do { x <- item;
item;
y <- item;
....}"
thanks for any help
jiangzhen <mail:jiangzhen3s at qq.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110718/c33dde23/attachment-0001.htm>
More information about the Beginners
mailing list