The Plus
typeclass provides monoid-like operations on type constructors instead of values.
The Plus
typeclass extends the Alt
typeclass.
The Plus
typeclass provides a single method, which returns the identity element of the alt
operation defined by the Alt
instance.
interface Plus extends Alt
{
/**
* @return F<A>
*/
public function empty();
}
Its simplified type is
empty :: () -> F<A>
The Plus
typeclass requires several laws to hold, in addition to the ones required by the Alt
typeclass.
$alternative->alt($alternative->empty(), $x) == $x
$alternative->alt($x, $alternative->empty()) == $x
$alternative->map($f, $alternative->empty()) == $alternative->empty()
EitherPlus