No, Error not a monad. Either e is a monad, and Error e is a prerequisite for a Monad instance for Either e . Basically, Error e means that e is the type with which you can convert error messages to strMsg , which was used for the Either e fail method.
However, people found that this requirement has an instance of Error e in order to be able to use Either e as a monad, annoying, so after LYAH was written, it was actually deleted. Now the instance is just
instance Monad (Either e) where return = Right Left l >>= _ = Left l Right r >>= k = kr
and fail instead uses the default value from the Monad class definition:
fail s = error s
However, the Error e requirement is still required (at least for the new Haskell platform) for monads and transformers defined in Control.Monad.Error , while Control.Monad.Either does not meet this requirement.
source share