
19 Aug
2011
19 Aug
'11
4:40 p.m.
I've created a simple type declaration: data MathExpression = Float | Add MathExpression MathExpression | Subtract MathExpression MathExpression | Multiply MathExpression MathExpression | Divide MathExpression MathExpression deriving (Show) Now how do I create an instance of MathExpression which is just a Float? This doesn't work: *Main> let pi = 3.14 :: MathExpression <interactive>:1:10: No instance for (Fractional MathExpression) arising from the literal `3.14' Possible fix: add an instance declaration for (Fractional MathExpression) In the expression: 3.14 :: MathExpression In an equation for `pi': pi = 3.14 :: MathExpression