[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] lawless instances of Functor

Subject: Re: [Haskell-cafe] lawless instances of Functor
From: Steffen Schuldenzucker
Date: Tue, 05 Jan 2010 22:15:40 +0100
Brent Yorgey wrote:
> On Mon, Jan 04, 2010 at 11:49:33PM +0100, Steffen Schuldenzucker wrote:
>> [...]
> 
> As others have pointed out, this doesn't typecheck; but what it DOES
> show is that if we had a type class
> 
>   class Endofunctor a where
>     efmap :: (a -> a) -> f a -> f a
> 
> then it would be possible to write an instance for which efmap id = id
> but efmap (f . g) /= efmap f . efmap g.  The difference is that with
> the normal Functor class, once you have applied your function f :: a
> -> b to get a b, you can't do anything else with it, since you don't
> know what b is.  With the Endofunctor class, once you have applied f
> :: a -> a, you CAN do something with the result: namely, apply f
> again.  

Oops. Yeah, sorry, it's been ... late and stuff...

Steffen

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>