
[Moved to -cafe at SPJ's request]
"Serge D. Mechveliani"
On Mon, Apr 26, 2004 at 10:09:18PM +0200, Ketil Malde wrote:
"Serge D. Mechveliani"
writes:
length :: [a] -> Integer smallLength :: [a] -> Int
Hmm...isn't it possible to use a class here? Perhaps even Num?
I think, for many functions, like length, it is most natural to return Integer only.
Well, perhaps Integral is a better choice. I was perhaps thinking of functions like: average xs = sum xs / length xs I'd rather have a polymorphic "length", than different versions for each possible return type. One problem could be that with average xs = sum xs / fromIntegral (length xs) the return type of length becomes ambigous? -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (1)
-
Ketil Malde