I don't see it here by the definition of EitherT
, nor here by the definition of Applicative
.
Shouldn't it be defined within the type module or within the typeclass module, to avoid being orphaned? Where is it?
CodePudding user response:
EitherT
is defined as type EitherT = ExceptT
. Unlike newtype
wrappers which need their own instances, type
aliases share instances. And the instance for ExceptT
is defined in Control.Monad.Trans.Except
in the transformers
package.
CodePudding user response:
The docs page you linked for EitherT
clearly shows that EitherT
is a type alias:
type EitherT =
ExceptT
Type alias for ExceptT
That means it cannot have its own instances; any instances it has will be defined for the type it is an alias for; in this case ExceptT
.
Conveniently, it also links to the docs for ExceptT
. Inconveniently, it links those two occurrences of ExceptT
to different URLs! One of them seems to be a broken link (to a module that exists in mtl
, as if it existed in the transformers-either
package), but the other one works, and shows:
(Functor m, Monad m) => Applicative (ExceptT e m)