All Monads are Functors
Taral
taralx at gmail.com
Mon Aug 14 01:02:58 EDT 2006
On 8/13/06, Lennart Augustsson <lennart at augustsson.net> wrote:
> If I remember right, Functor was a superclass of Monad in Haskell
> early on, but it was taken away. I think this was the wrong
> decision, but I seem to remember that the rationale was that it would
> be too onerous to require programmers to write a Functor instance
> every time they want a Monad instance. Bah!
There was a proposal (Re: [Haskell] A collection of related proposals
regarding monads) to allow instance definitions to be combined,
allowing a more fine-grained hierarchy (Functor, PointedFunctor,
Applicative, Monad) without changing the instance definition
requirements.
In my opinion, an instance definition of a subclass should allow the
superclass's methods to be defined as if they were part of the
subclass, e.g.:
instance Monad [] where
fmap = map
return x = [x]
join = concat
It's so pretty! (But a little inefficient. You'd probably want to
define ap/lift2 in there.)
--
Taral <taralx at gmail.com>
"You can't prove anything."
-- Gödel's Incompetence Theorem
More information about the Haskell-prime
mailing list