Class Head<A>
- java.lang.Object
-
- com.jnape.palatable.lambda.functions.builtin.fn1.Head<A>
-
- Type Parameters:
A
- the Iterable element type
- All Implemented Interfaces:
Fn1<java.lang.Iterable<A>,Maybe<A>>
,Applicative<Maybe<A>,Fn1<java.lang.Iterable<A>,?>>
,Cartesian<java.lang.Iterable<A>,Maybe<A>,Fn1<?,?>>
,Cocartesian<java.lang.Iterable<A>,Maybe<A>,Fn1<?,?>>
,Contravariant<java.lang.Iterable<A>,Profunctor<?,Maybe<A>,Fn1<?,?>>>
,Functor<Maybe<A>,Fn1<java.lang.Iterable<A>,?>>
,Profunctor<java.lang.Iterable<A>,Maybe<A>,Fn1<?,?>>
,Monad<Maybe<A>,Fn1<java.lang.Iterable<A>,?>>
,MonadReader<java.lang.Iterable<A>,Maybe<A>,Fn1<java.lang.Iterable<A>,?>>
,MonadRec<Maybe<A>,Fn1<java.lang.Iterable<A>,?>>
,MonadWriter<java.lang.Iterable<A>,Maybe<A>,Fn1<java.lang.Iterable<A>,?>>
public final class Head<A> extends java.lang.Object implements Fn1<java.lang.Iterable<A>,Maybe<A>>
Retrieve the head element of anIterable
, wrapped in anMaybe
. If theIterable
is empty, the result isMaybe.nothing()
.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Head()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Maybe<A>
checkedApply(java.lang.Iterable<A> as)
Invoke this function with the given argument, potentially throwing anyThrowable
.static <A> Head<A>
head()
static <A> Maybe<A>
head(java.lang.Iterable<A> as)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
INSTANCE
private static final Head<?> INSTANCE
-
-
Method Detail
-
checkedApply
public Maybe<A> checkedApply(java.lang.Iterable<A> as)
Description copied from interface:Fn1
Invoke this function with the given argument, potentially throwing anyThrowable
.- Specified by:
checkedApply
in interfaceFn1<java.lang.Iterable<A>,Maybe<A>>
- Parameters:
as
- the argument- Returns:
- the result of the function application
-
head
public static <A> Head<A> head()
-
head
public static <A> Maybe<A> head(java.lang.Iterable<A> as)
-
-