
17 Jan
2009
17 Jan
'09
7:04 a.m.
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?