[Haskell-cafe] Re: [Haskell] Re: sizeFM type

Ketil Malde ketil+haskell at ii.uib.no
Tue Apr 27 10:44:40 EDT 2004

[Moved to -cafe at SPJ's request]

"Serge D. Mechveliani" <mechvel at botik.ru> writes:

> On Mon, Apr 26, 2004 at 10:09:18PM +0200, Ketil Malde wrote:
>> "Serge D. Mechveliani" <mechvel at botik.ru> 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?

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list