[Haskell-cafe] A simple question
Marc Charpentier
mc at 3virgule14.net
Tue Nov 2 15:53:28 EST 2004
Good evening,
Doing some calculations in ghci, I encountered a difficulty which I
cannot resolve.
Here's a distilled version, prepared for the command line:
let i = 2 in (-1)^i/(2^(10*i)) * (-2^5/(4*i+1))
gives the following error messages
ghci:
Ambiguous type variable `b' in these top-level constraints:
`Fractional b' arising from use of `/' at <interactive>:1
`Integral b' arising from use of `^' at <interactive>:1
hugs:
ERROR - Unresolved overloading
*** Type : (Integral a, Fractional a) => a
*** Expression : let {...} in (-1) ^ i / 2 ^ (10 * i) * negate (2 ^ 5
/ (4 * i + 1))
However, if I substitute i = 2 in the last fraction, then the
transformed expression
let i = 2 in (-1)^i/(2^(10*i)) * (-2^5/(4*2+1))
is accepted.
Note that both
let i=2 in (-1)^i/(2^(10*i))
and
let i=2 in (-2^5/(4*i+1))
are accepted.
Why?
Thank you in advance.
Marc Charpentier
More information about the Haskell-Cafe
mailing list