Stable location for monomorphic foldr?

Edward Kmett ekmett at gmail.com
Wed Apr 1 19:59:02 UTC 2015


The culprit seems to be that

instance Foldable [] where

    elem    = List.elem    foldl   = List.foldl    foldl'  =
List.foldl'    foldl1  = List.foldl1    foldr   = List.foldr    foldr1
 = List.foldr1    length  = List.length    maximum = List.maximum
minimum = List.minimum    null    = List.null    product =
List.product    sum     = List.sum    toList  = id

delegates to monomorphic methods rather than implementing them directly.

The early testing where we showed that it didn't break RULES was done with
the final definitions in the class rather than delegating to GHC.OldList.

Somewhere when reorganizing of the code we switched to this style and
introduced this problem, making RULES much more brittle. =/

-Edward

On Wed, Apr 1, 2015 at 7:14 AM, Joachim Breitner <mail at joachim-breitner.de>
wrote:

> Hi,
>
> I just stumbled over a FTP breakage: A RULES with "foldr" on the left
> hand side would no longer fire, because it would refer to
> Foldable.foldr, and not the monomorphic foldr.
>
> Adding
> #if MIN_VERSION_base(4,8,0)
> import Prelude hiding (foldr)
> import GHC.OldList (foldr)
> #endif
> to the file solved the problem for now, but GHC.OldList is supposed to
> go away eventually, so I believe we need a permanent location for the
> monomorphic foldr.
>
> Or will we simply not get rid of GHC.OldList at all?
>
> (One could argue that "foldr" on the left-hand-side of a RULE should
> work and that this is a GHC bug, though.)
>
> Greetings,
> Joachim
>
> --
> Joachim “nomeata” Breitner
>   mail at joachim-breitner.dehttp://www.joachim-breitner.de/
>   Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0xF0FBF51F
>   Debian Developer: nomeata at debian.org
>
> _______________________________________________
> Libraries mailing list
> 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/20150401/cebc28b2/attachment.html>


More information about the Libraries mailing list