Proposal: Add missing Foldable/Traversable instances for Prelude types

kahl at cas.mcmaster.ca kahl at cas.mcmaster.ca
Sat Jan 22 19:25:59 CET 2011


On Sat, Jan 22, 2011 at 05:12:00PM +0100, Bas van Dijk wrote:
> On 22 January 2011 05:16, Edward Kmett <ekmett at gmail.com> wrote:
> > I went with the default being to avoid prematurely forcing a bottom when
> > possible, to avoid being called out by the strictness police, but I'm not
> > terribly wedded to the behavior.
> 
> Just for reference, the Functor instance on pairs is strict in the pair:
> 
> instance Functor ((,) a) where
>         fmap f (x,y) = (x, f y)

And this is necessary for the functor laws, because with

  fmap' f ~(x,y) = (x, f y)

we obtain:

  fmap' id undefined = (undefined, undefined) /= undefined = id undefined


Wolfram



More information about the Libraries mailing list