In ML books; functors only consume & produce structures; whereas, functions C&P values.

I've never seen such an easy description in Haskell books. Is there more going on with Haskell functors? -- -- Regards, KC

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

On Fri, Jun 10, 2011 at 07:53:58PM -0700, KC wrote:
I've never seen such an easy description in Haskell books.
Is there more going on with Haskell functors?
Note that ML functors and Haskell functors are different things. ML functors are parameterized modules. Haskell functors are types which are instances of the Functor class. I think 'functor' is a bad name for the ML concept, but of course I'm somewhat biased. -Brent
participants (3)
-
Brent Yorgey
-
Chris Smith
-
KC