I am trying to define a new monad and I am getting a strange error
newmonad.hs
newtype Wrapped a = Wrap {unwrap :: a} instance Monad Wrap
The most normalized and unobtrusive answer is :-
as Monad is dependent upon Applicative
class Applicative m => Monad m where ...
and Applicative is dependent upon Functor
class Functor f => Applicative f where ...
we need the instance definitions
> instance Functor Wrapped where
> fmap = liftM
and
> instance Applicative Wrapped where
> pure = return
> (<*>) = ap