
22 Jan
2011
22 Jan
'11
3:02 p.m.
On Sat, 22 Jan 2011, kahl@cas.mcmaster.ca wrote:
On Sat, Jan 22, 2011 at 05:12:00PM +0100, Bas van Dijk wrote:
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
Thank you lot! I already wondered for similar data structures how to define fmap the correct way. But then I see, that transformers:WriterT.Lazy matches lazily, too: http://hackage.haskell.org/packages/archive/transformers/0.2.2.0/doc/html/sr...