The Alternative
typeclass provides monoid-like operations on type constructors instead of values.
The Alternative
typeclass extends the Applicative
typeclass and the Plus
typeclass.
The Alternative
typeclass do not expose any new method with respect to Applicative
and Plus
.
The Alternative
typeclass require more laws to hold, in addition to the ones required by the Applicative
and Plus
typeclasses.
$alternative->apply($alternative->alt($f, $g), $x) == $alternative->alt($alternative->apply($f, $x), $alternative->apply($g, $x))
$alternative->apply($alternative->empty(), $f) == $alternative->empty()
EitherAlternative