
hi test :: Parser (Char,Char) test = do x <- item item y <- item return (x,y) How come this brings an error saying that after do {....} it must end with an expression. Ryan _________________________________________________________________ Get free emoticon packs and customisation from Windows Live. http://www.pimpmylive.co.uk

On Dec 8, 2007, at 21:38 , Ryan Bloor wrote:
test :: Parser (Char,Char) test = do x <- item item
The second and subsequent lines are indented too much, so are read as a continuation of the first; which, starting with "x <- ", is not an expression. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Dec 8, 2007, at 21:40 , Brandon S. Allbery KF8NH wrote:
On Dec 8, 2007, at 21:38 , Ryan Bloor wrote:
test :: Parser (Char,Char) test = do x <- item item
The second and subsequent lines are indented too much, so are read as a continuation of the first; which, starting with "x <- ", is not an expression.
I neglected to say the proper indentation: test = do x <- item item -- note, indented to match the token after the "do" y <- item return (x,y) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Dec 9, 2007 12:42 AM, Brandon S. Allbery KF8NH
I neglected to say the proper indentation:
test = do x <- item item -- note, indented to match the token after the "do" y <- item return (x,y)
That is the best thing to do. If you don't like the identation rule, you may also use explicit semicolons as in test = do {x <- item; item; y <- item; return (x,y)} or maybe test = do {x <- item; item; y <- item; return (x,y)} or even test = do { x <- item; item ; y <- item ; return (x,y)} Of course, in the last example you lost all the legibility of your code, but it compiles =). HTH, -- Felipe.
participants (3)
-
Brandon S. Allbery KF8NH
-
Felipe Lessa
-
Ryan Bloor