Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 876 Bytes

Plus.md

File metadata and controls

51 lines (34 loc) · 876 Bytes

Plus

The Plus typeclass provides monoid-like operations on type constructors instead of values.

Parent

The Plus typeclass extends the Alt typeclass.

API

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>

Laws

The Plus typeclass requires several laws to hold, in addition to the ones required by the Alt typeclass.

Left identity

$alternative->alt($alternative->empty(), $x) == $x

Right identity

$alternative->alt($x, $alternative->empty()) == $x
$alternative->map($f, $alternative->empty()) == $alternative->empty()

Implemented instances

  • EitherPlus