Hi !
I've tried to implement the expression interpreter present in Data types a la carte, putting the new "cases" of my data type in a separate module. When I'm trying to create a simple
expression like this:
x :: Expr (Val :+: Add :+: Mult)
x = (val 2000 `mult` val 399) `plus` (val 3)
I'm getting the following type error that I can't solve:
src/Main.hs:25:4:
No instance for (Add :<: Mult)
arising from a use of `plus' at src/Main.hs:25:4-43
Possible fix: add an instance declaration for (Add :<: Mult)
In the expression: (val 2000 `mult` val 399) `plus` (val 3)
In the definition of `x':
x = (val 2000 `mult` val 399) `plus` (val 3)
src/Main.hs:25:5:
No instance for (Val :<: Mult)
arising from a use of `val' at src/Main.hs:25:5-12
Possible fix: add an instance declaration for (Val :<: Mult)
In the first argument of `mult', namely `val 2000'
In the first argument of `plus', namely `(val 2000 `mult` val 399)'
In the expression: (val 2000 `mult` val 399) `plus` (val 3)
I've attached the source code...
Regards
Rodrigo