Proposal: Add a few extra members to Foldable and Traversable classes

Joachim Breitner mail at
Fri Sep 19 20:59:08 UTC 2014


Am Freitag, den 19.09.2014, 22:29 +0200 schrieb Henning Thielemann:
> Unfortunately, it is not only hard to 
> predict when RULES fire, a RULES based solution is also dangerous. If a 
> default method implementation and an actual instance implementation do 
> different things, that's ok. In contrast, if a function is replaced by 
> different functionality via RULES, that's very bad.

I meant rules provided by whoever implements the class:

        instance Traversable Foo where..
        {-# RULES "sum/Foo" forall fx :: Foo Int . sum (toList fx) = sumFoo xs #-}

so there would be no worry about soundness.

I do _not_ mean adding such rules to where the class is defined.

(This assumes that GHC does the right thing when the overloaded toList
occurs in a rule, which I am not sure of.)


Joachim “nomeata” Breitner
  mail at joachim-breitner.de
  Jabber: nomeata at  • GPG-Key: 0xF0FBF51F
  Debian Developer: nomeata at

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the Libraries mailing list