On 6 September 2010 16:15, wren ng thornton <w...@freegeek.org> wrote: > 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)?
Well, if we consider what this does, pure is equivalent to singleton for container types. The actual definition of pure (or any other aspect of Pointed) doesn't require Functor; however there are properties for types that are instances of Functor and Pointed. So, from a proof/testing POV having Functor as a superclass is nice; from an implementation POV it doesn't seem to be needed. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe