I want to write a data type to evaluate the expressions like this:
a
is evaluated to a
a + b * c / d -e
is evaluated to a + (b * (c / (d - e)))
So the first argument is always a number and the second one is either a number or an expression
I have tried to define a data type like this
data Exp = Single Int
| Mult (Single Int) Exp
But it gives me this compilation error:
Not in scope: type constructor or class ‘Single’
A data constructor of that name is in scope; did you mean DataKinds?
|
9 | | Mult (Single Integer ) Exp
|
I can define it like this:
data Exp = Single Integer
| Mult Exp Exp
But it does not give the precise definition of the Type I want. How can I define this?