[Haskell-cafe] Textbook example of instance Foldable ((,) a)

Henning Thielemann lemming at henning-thielemann.de
Tue Nov 24 09:20:58 UTC 2020


On Tue, 24 Nov 2020, Viktor Dukhovni wrote:

> Rather than waiting, it is perhaps more pragmatic to go with a custom
> Prelude, which one can have now, even for versions of GHC/base, that
> won't have the feature in question:

I have such a Prelude:
    https://hackage.haskell.org/package/prelude-compat

It helps a bit, but does not fully solve the problem.

If you use Fold.all on a Map and then switch from Map k a to (Map k a, b) 
you will again not encounter a warning nor a type error.



I had the idea of implementing forbidden instances like:

instance Unsatisfiable a => Foldable ((,) a) where

If I use them (or import them?) they would conflict with the one from 
FTP-Prelude. I have not tried that idea. It might exclude importing code 
that uses Foldable on pair intentionally.


More information about the Haskell-Cafe mailing list