A
- the Maybe value parameter typepublic final class First<A> extends Object implements Monoid<Maybe<A>>
Monoid
instance formed by Maybe
<A>
. The application to two Maybe
values
produces the first non-empty value, or Maybe.nothing()
if all values are empty.Modifier and Type | Method and Description |
---|---|
Maybe<A> |
checkedApply(Maybe<A> x,
Maybe<A> y) |
static <A> First<A> |
first() |
static <A> Fn1<Maybe<A>,Maybe<A>> |
first(Maybe<A> x) |
static <A> Maybe<A> |
first(Maybe<A> x,
Maybe<A> y) |
<B> Maybe<A> |
foldMap(Fn1<? super B,? extends Maybe<A>> fn,
Iterable<B> bs)
Homomorphism combined with catamorphism.
|
Maybe<A> |
identity()
The identity element of this monoid.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
flip, foldLeft, foldRight, monoid, monoid, reduceLeft, reduceRight
apply, apply, checkedApply, compose, contraMap, curried, curry, diMapL, discardR, fn2, fromBiFunction, toBiFunction, uncurry, widen
public Maybe<A> identity()
Monoid
public <B> Maybe<A> foldMap(Fn1<? super B,? extends Maybe<A>> fn, Iterable<B> bs)
Monoid
Iterable<B>
to an
Iterable<A>
(that is, an Iterable
of elements this monoid is formed over), then
reduce the result from left to right. Under algebraic data types, this is isomorphic to a flatMap.public static <A> First<A> first()