Suggestion regarding (.) and map

apfelmus apfelmus at quantentunnel.de
Fri Apr 25 07:34:35 EDT 2008


Dan Doel wrote:
> If you do want to generalize (.), you have to decide whether you 
> want to generalize it as composition of arrows, or as functor application. 
> The former isn't a special case of the latter (with the current Functor, at 
> least).

By annotating functors with the category they operate on, you can 
reconcile both seemingly different generalizations

    class Category (~>) => Functor (~>) f where
       (.) :: (a ~> b) -> (f a -> f b)

       -- functor application
    instance Functor (->) [] where
       (.) = map

       -- arrow composition
    instance Category (~>) => Functor (~>) (d ~>) where
       (.) = (<<<)


Regards,
apfelmus



More information about the Haskell-prime mailing list