[Haskell-cafe] Functors [Comments from OCaml Hacker Brian Hurt]

Andrew Coppin andrewcoppin at btinternet.com
Sat Jan 17 07:04:01 EST 2009


Eugene Kirpichov wrote:
> No, a functor is a more wide notion than that, it has nothing to do
> with collections.
> An explanation more close to truth would be "A structure is a functor
> if it provides a way to convert a structure over X to a structure over
> Y, given a function X -> Y, while preserving the underlying
> 'structure'", where preserving structure means being compatible with
> composition and identity.
>   

As far as I'm aware, constraints like "while preserving the underlying 
structure" are not expressible in Haskell.

> instance (Monad m) => Functor m where
>   fmap f ma = do a <- ma; return (f a)
>   

While that's quite interesting from a mathematical point of view, how is 
this "useful" for programming purposes?



More information about the Haskell-Cafe mailing list