On Mon, Jan 4, 2010 at 3:01 PM, Derek Elkins <[email protected]> wrote: > So without doing funky stuff involving bottoms and/or seq, I believe > that fmap id = id implies the other functor law (in this case, not in > the case of the general categorical notion of functor.)
So lets play with bottoms and/or seq. > data X a = X a > instance Functor X where > fmap f x = f `seq` case x of X a -> f a fmap id x = id `seq` case x of X a -> X (id a) = case x of X a -> X a = id x fmap (const () . undefined) x = fmap (\a -> const () (undefined a)) x = fmap (\a -> ()) x = case x of X a -> X () (fmap (const ()) . fmap undefined) x = fmap (const ()) (fmap undefined x) = const () `seq` case (fmap undefined x) of X a -> X () = case (fmap undefined x) of X a -> X ()) = case (undefined `seq` case x of X a -> X (undefined a)) of X a -> X () = case undefined of X a -> X () = undefined _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
