[Haskell-cafe] Parser question

Mark Carroll markc at chiark.greenend.org.uk
Tue Mar 15 07:38:42 EST 2005

On Tue, 15 Mar 2005, Nicola Whitehead wrote:
> term :: Parser Int
> term = do f <- factor
>                do symbol "*"
>                e <- expr
>                return (f * t)
>           +++ return f

> symbol and natural are defined elsewhere and work fine, but when I compile it I get the error
> ERROR "C:/HUGS/Calculator.hs":66 - Undefined variable "t"    
> I suspect I'm missing something obvious, but for the life of me I can't see it. Any suggestions?

You are missing something obvious. (-: "t" appears indeed to be undefined
in "term". Did you mean "return (f * e)"? Variables (although why they're
called that in Haskell I'm not sure) defined with <- in "do" are only in
scope later in that "do", not anywhere else.


Haskell vacancies in Columbus, Ohio, USA: see http://www.aetion.com/jobs.html

More information about the Haskell-Cafe mailing list