[Haskell-cafe] Parser question

2005-03-15 Thread Nicola Whitehead
Hi folks, I have a parser problem. I have a basic calculator program (Graham Hutton's from Nottingham) which contains the following code: -- Define a parser to handle the inputexpr :: Parser Intexpr = do t - term do symbol "+" e - expr return (t + e) +++ return t term :: Parser

[Haskell-cafe] Parser problem continued

2005-03-15 Thread Nicola Whitehead
Curiouser and curiouser... expr :: Parser Intexpr = do t - term do symbol "+"e - expr return (t + e) +++ return t solves the undefined variable problem but introduces a new 'Last operator in do {...} must be an _expression_' error, which then disappears if I explicitly return e expr

RE: [Haskell-cafe] Parser problem continued

2005-03-15 Thread Nicola Whitehead
perhaps like this: expr = do t - term (do symbol + e - expr return (t+e) ) +++ (return t) although I think you may also want a 'try' before the first alternative. No, that still gives the same undefined variable error.

RE: [Haskell-cafe] Parser problem continued

2005-03-15 Thread Nicola Whitehead
Thanks folks! Writing it in a lispy manner seems to work. I see what Arthur means about the layout - I think I'm still thinking too much in C. :) Nik Dr Nik FreydĂ­s Whitehead University of Akureyri, Iceland * Having the moral