[Haskell-cafe] In ML books; functors only consume & produce structures; whereas, functions C&P values.

Chris Smith cdsmith at gmail.com
Sat Jun 11 05:06:04 CEST 2011


On Fri, 2011-06-10 at 19:53 -0700, KC wrote:
> I've never seen such an easy description in Haskell books.
> 
> Is there more going on with Haskell functors?

You could make an analogous statement by saying that Haskell functors
produce and consume types... but we don't, because that's a much more
general concept than a functor really is.  Rather, types of kind
(* -> *) are what produce and consume types.  Functors are types of kind
(* -> *) that also come with a built-in notion of lifting functions
between two types into functions between the types the functor gives you
from them, in a way that preserves function composition.  Some (perhaps
most) types with the expected kind are functors; but being a functor is
extra structure beyond merely having that kind.

I'm not familiar enough with ML to say anything for sure about the ML
version of a functor; but I suspect that such a short description there
is also inadequate, and there's also a kind of structure-preserving
property that needs to be stated there as well.

-- 
Chris Smith





More information about the Haskell-Cafe mailing list