I know that Functor and Applicative should be superclasses of Monad, but aren't for historical reasons. However, why isn't is possible to declare Monad an instance of Functor? This would have roughly the same effect, but without having to modify existing code. If you're trying to do this, GHC complains:
instance Functor Monad where
fmap = liftM
Class `Monad' used as a type
In the instance declaration for `Functor Monad'
Why is that? There's probably a good reason for it.
Your syntax is wrong. Monad is a typeclass, not a data type. What you could write is
instance Monad a => Functor a where fmap = liftM
However, this will only work with the extensions FlexibleInstances (permits instances that are not of the form T a1 a2 ... an where a1, a2, ... an are type variables and there is no context) and UndecidableInstances (which permits this specific instance [I don't know why this is needed]).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With