Hello,<br><br>I am a somewhat experienced programmer and a complete Haskell newbie, so I hope this is the correct ML for my question.<br><br>I have decided to learn Haskell and started with Graham Hutton's book. Everything was going nicely until section
8.4, on sequencing functional parsers. I am trying to write an elementary parser that produces the 1st and 3d elements from a string. I am using the code from the book.<br><br>---------------------<br><br>
type Parser a = String -> [(a, String)]<br>
<br>
return :: a -> Parser a<br>
return v = \inp -> [(v, inp)]<br>
<br>
failure :: Parser a<br>
failure = \inp -> []<br>
<br>
<br>
item :: Parser Char<br>
item = \inp -> case inp of<br>
[] -> []<br>
(x:xs) -> [(x, xs)]<br>
<br>
<br>
parse :: Parser a -> String -> [(a, String)]<br>
parse p inp = p inp<br>
<br>
<br>
(>>=) :: Parser a -> (a -> Parser b) -> Parser b<br>
p >>= f = \inp -> case parse p inp of<br>
[] -> []<br>
[(v, out)] -> parse (f v) out<br>
<br>
<br>
p :: Parser (Char, Char)<br>
p = do x <- item<br>
item<br>
y <- item<br>
return (x, y) -- LINE 34<br>
--------------------<br><br>BUT, when I try to :load parse.hs from hugs I get the following error:<br><br>ERROR "parse.hs":34 - Last generator in do {...} must be an expression<br><br><br>
I have no idea what I am doing wrong and why Hugs is complaining. I hope this question is not too simply for this mailing list, but I have honestly googled for an answer and had found nothing. <br><br><br><br>Juozas Gaigalas
<br>
<br>
<br>