[Haskell-cafe] Restricted type classes

wren ng thornton wren at freegeek.org
Mon Sep 6 02:15:37 EDT 2010


On 9/5/10 10:19 AM, Ivan Lazar Miljenovic wrote:
> Hmmm.... is there any reason for Functor to be a superclass of
> Pointed?  I understand Functor and Pointed being superclasses of
> Applicative (which in turn is a superclass of Monad), but can't see
> any relation between Pointed and Functor...

Because there's a law for pointed functors which ensures that return 
(point, unit, pure,...) only creates "trivial" structure:

     forall {A B : Type} (f : A -> B) (a : A)
          , fmap f (return a) = return (f a)

If we require this law, then the five laws for Applicative can be 
reduced to only three; which is nice. (Though, if the extra two laws are 
satisfied, then we can prove this one.)

We don't actually enforce that instances obey their class' laws anywhere 
else, so it's not like we'd need somewhere to store this proof. But the 
law is there nevertheless. What use would it be to have a return 
function that doesn't satisfy any laws (i.e., without fmap)?

-- 
Live well,
~wren


More information about the Haskell-Cafe mailing list