
Constructor definitions take type arguments but you have given it
another constructor. To fix this, you might want to create a Variable
datatype and reference it in the Expresion datatype and the Statement
datatype but it's hard (for me) to know without further information.
On Sat, Feb 5, 2011 at 12:33 PM, Tyler Hayes
As an exercise, I'm attempting to create an abstract syntax tree for a very small language:
data Expression = Variable String | Integer | Expression BinOp Expression deriving Show
data Statement = Assignment Variable Expression --error! | If Expression Statement Statement | While Expression Statement | Compound Statement deriving Show
data BinOp = Add | Mult | LessThan | GreaterThan deriving Show
However, there is a problem with having "Variable" as an argument to the "Assignment" constructor of the "Statement" data type:
Prelude> :l test.hs [1 of 1] Compiling Test ( test.hs, interpreted )
test.hs:8:28: Not in scope: type constructor or class `Variable' Failed, modules loaded: none.
An 'assignment' is a variable followed by an expression in this example, so what can I do to fix this?
Thanks, Tyler
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners