[NumericPrelude] Bug in Numeric Prelude or GHC?
Grigory Sarnitskiy
sargrigory at ya.ru
Sat Jun 18 12:42:59 BST 2011
Hello! I have a problem with -x syntax --- it doesn't work, only negate x. I've made my type Expression a to be an instance of Additive:
instance (C a, Ord a) => C (Expression a) where
zero = Const zero
negate x = ITimes (-1) x
x + y = Sum [x, y]
And I have:
*Main> negate b :: Expression Integer
(-1) b
*Main> zero - b :: Expression Integer
0 + (-1) b
*Main> -b :: Expression Integer
<interactive>:1:1:
No instance for (GHC.Num.Num (Expression Integer))
arising from a use of syntactic negation
Possible fix:
add an instance declaration for (GHC.Num.Num (Expression Integer))
In the expression: - b :: Expression Integer
In an equation for `it': it = - b :: Expression Integer
I hoped that providing negate for my type would be enough to us -x instead of negate x. So I wonder is it a GHC issue of numeric-prelude's one?
I'm using numeric-prelude 0.2.1, GHC 7.0.3, Ubuntu 11.04 64 bit.
More information about the Numeric-Prelude
mailing list