Proposal: Add missing Foldable/Traversable instances for Prelude types
Henning Thielemann
lemming at henning-thielemann.de
Sat Jan 22 21:02:52 CET 2011
On Sat, 22 Jan 2011, kahl at 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/src/Control-Monad-Trans-Writer-Lazy.html#WriterT
More information about the Libraries
mailing list