[Haskell-cafe] Question about data
paul.reiners at gmail.com
Fri Aug 19 22:40:45 CEST 2011
I've created a simple type declaration:
data MathExpression = Float
| Add MathExpression MathExpression
| Subtract MathExpression MathExpression
| Multiply MathExpression MathExpression
| Divide MathExpression MathExpression
Now how do I create an instance of MathExpression which is just a Float?
This doesn't work:
*Main> let pi = 3.14 :: MathExpression
No instance for (Fractional MathExpression)
arising from the literal `3.14'
add an instance declaration for (Fractional MathExpression)
In the expression: 3.14 :: MathExpression
In an equation for `pi': pi = 3.14 :: MathExpression
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe