Class First<A>
- java.lang.Object
-
- com.jnape.palatable.lambda.monoid.builtin.First<A>
-
- Type Parameters:
A
- the Maybe value parameter type
- All Implemented Interfaces:
Fn1<Maybe<A>,Fn1<Maybe<A>,Maybe<A>>>
,Fn2<Maybe<A>,Maybe<A>,Maybe<A>>
,Applicative<Fn1<Maybe<A>,Maybe<A>>,Fn1<Maybe<A>,?>>
,Cartesian<Maybe<A>,Fn1<Maybe<A>,Maybe<A>>,Fn1<?,?>>
,Cocartesian<Maybe<A>,Fn1<Maybe<A>,Maybe<A>>,Fn1<?,?>>
,Contravariant<Maybe<A>,Profunctor<?,Fn1<Maybe<A>,Maybe<A>>,Fn1<?,?>>>
,Functor<Fn1<Maybe<A>,Maybe<A>>,Fn1<Maybe<A>,?>>
,Profunctor<Maybe<A>,Fn1<Maybe<A>,Maybe<A>>,Fn1<?,?>>
,Monad<Fn1<Maybe<A>,Maybe<A>>,Fn1<Maybe<A>,?>>
,MonadReader<Maybe<A>,Fn1<Maybe<A>,Maybe<A>>,Fn1<Maybe<A>,?>>
,MonadRec<Fn1<Maybe<A>,Maybe<A>>,Fn1<Maybe<A>,?>>
,MonadWriter<Maybe<A>,Fn1<Maybe<A>,Maybe<A>>,Fn1<Maybe<A>,?>>
,Monoid<Maybe<A>>
,Semigroup<Maybe<A>>
public final class First<A> extends java.lang.Object implements Monoid<Maybe<A>>
AMonoid
instance formed by
. The application to twoMaybe
<A>Maybe
values produces the first non-empty value, orMaybe.nothing()
if all values are empty.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
First()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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, java.lang.Iterable<B> bs)
Homomorphism combined with catamorphism.Maybe<A>
identity()
The identity element of this monoid.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.jnape.palatable.lambda.functions.Fn1
andThen, carry, cartesian, censor, choose, cocartesian, diMap, diMapR, discardL, flatMap, fmap, lazyZip, listens, local, pure, self, thunk, toFunction, trampolineM, zip, zip
-
Methods inherited from interface com.jnape.palatable.lambda.functions.Fn2
apply, apply, checkedApply, compose, contraMap, diMapL, discardR, toBiFunction, uncurry, widen
-
Methods inherited from interface com.jnape.palatable.lambda.monoid.Monoid
flip, foldLeft, foldRight, reduceLeft, reduceRight
-
-
-
-
Field Detail
-
INSTANCE
private static final First<?> INSTANCE
-
-
Method Detail
-
identity
public Maybe<A> identity()
Description copied from interface:Monoid
The identity element of this monoid.
-
foldMap
public <B> Maybe<A> foldMap(Fn1<? super B,? extends Maybe<A>> fn, java.lang.Iterable<B> bs)
Description copied from interface:Monoid
Homomorphism combined with catamorphism. Convert anIterable<B>
to anIterable<A>
(that is, anIterable
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.- Specified by:
foldMap
in interfaceMonoid<A>
- Type Parameters:
B
- the input Iterable element type- Parameters:
fn
- the mapping function from A to Bbs
- the Iterable of Bs- Returns:
- the folded result under this Monoid
- See Also:
Map
,Monoid.reduceLeft(Iterable)
-
first
public static <A> First<A> first()
-
-