Generalizing some type signatures involving Int

Alexandre Rodrigues alexandreR_B at
Wed Nov 14 18:04:25 UTC 2018

I spoke too soon, I failed to consider that such a proposal must have been under consideration many times before, and there must have been a good reason for it to not to move forward.

Adding RULES for the most commonly used integer types is probably a good place to start, but perhaps I am mistaken.

From: Libraries <libraries-bounces at> on behalf of David Feuer <david.feuer at>
Sent: Wednesday, November 14, 2018 3:30:38 AM
To: Vanessa McHale
Cc: Haskell Libraries
Subject: Re: Generalizing some type signatures involving Int

That won't help whatsoever in most cases. The matter has been discussed several times with no progress. If you want to add RULES for Int8, Int16, ..., Word, Word8, ..., and Natural to match the ones for Int and Integer, that would make sense, but the basic problem will remain for unmentioned types.

On Tue, Nov 13, 2018, 10:24 PM Vanessa McHale <vanessa.mchale at<mailto:vanessa.mchale at> wrote:

This is perhaps not the right place, but if there are benchmarks proving that genericLength is slower than it should be, it should be easy to add a SPECIALIZE pragma.

On 11/13/18 9:13 PM, David Feuer wrote:
genericLength is extremely inefficient for typical numeric types. Int is a rather sad type for these things; it really should be Word. But that may not be worth fixing.

On Tue, Nov 13, 2018, 9:51 PM Evan Laforge <qdunkan at<mailto:qdunkan at> wrote:
You can already get these as Data.List.genericLength and

As for changing the prelude ones, this would probably cause a lot of
busywork.  Where I work we compile with -Werror and -Wtype-defaults,
so a lot of places might have to get type annotations.
On Tue, Nov 13, 2018 at 5:19 PM Vanessa McHale <vanessa.mchale at<mailto:vanessa.mchale at>> wrote:
> Would it be possible to generalize replicate and length to have type
> signatures
> replicate :: Integral a => a -> b -> [b]
> and
> length :: (Integral a, Foldable t) => t b -> a
> ?
> There have been a few instances where such a thing would have been
> useful to me.
> Cheers
> _______________________________________________
> Libraries mailing list
> Libraries at<mailto:Libraries at>
Libraries mailing list
Libraries at<mailto:Libraries at>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list