Generalizing some type signatures involving Int

Vanessa McHale vanessa.mchale at iohk.io
Wed Nov 14 03:24:11 UTC 2018


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 gmail.com
> <mailto:qdunkan at gmail.com> wrote:
>
>     You can already get these as Data.List.genericLength and
>     Data.List.genericReplicate
>
>     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 iohk.io <mailto:vanessa.mchale at iohk.io>> 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 haskell.org <mailto:Libraries at haskell.org>
>     > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>     _______________________________________________
>     Libraries mailing list
>     Libraries at haskell.org <mailto:Libraries at haskell.org>
>     http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20181113/5564ff58/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20181113/5564ff58/attachment.sig>


More information about the Libraries mailing list