
13 Nov
2001
13 Nov
'01
4:51 a.m.
At 2001-11-12 18:06, Jesper Louis Andersen wrote:
mean :: (Fractional a) => [a] -> a mean l = (sum l)/ fromIntegral (length l)
Which imposes a type constraint (of course). My problem is, that i cannot ``let go'' of this constraint.
...
main :: Fractional Int => IO ()
It sounds like you're trying to use your 'mean' function on Ints. Int is not a Fractional type (unless you make it one), and so '/' isn't defined on it. What's "mean [3::Int,4::Int]"? It can't be "3.5::Int" because 3.5 is not an integer and so not an Int. -- Ashley Yakeley, Seattle WA