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 Object implements Monoid<Maybe<A>>
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.
See Also:
  • Field Details

    • INSTANCE

      private static final First<?> INSTANCE
  • Constructor Details

    • First

      private First()
  • Method Details

    • identity

      public Maybe<A> identity()
      Description copied from interface: Monoid
      The identity element of this monoid.
      Specified by:
      identity in interface Monoid<A>
      Returns:
      the identity
    • checkedApply

      public Maybe<A> checkedApply(Maybe<A> x, Maybe<A> y)
      Specified by:
      checkedApply in interface Fn2<Maybe<A>,Maybe<A>,Maybe<A>>
    • foldMap

      public <B> Maybe<A> foldMap(Fn1<? super B,? extends Maybe<A>> fn, Iterable<B> bs)
      Description copied from interface: Monoid
      Homomorphism combined with catamorphism. Convert an 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.
      Specified by:
      foldMap in interface Monoid<A>
      Type Parameters:
      B - the input Iterable element type
      Parameters:
      fn - the mapping function from A to B
      bs - the Iterable of Bs
      Returns:
      the folded result under this Monoid
      See Also:
    • first

      public static <A> First<A> first()
    • first

      public static <A> Fn1<Maybe<A>,Maybe<A>> first(Maybe<A> x)
    • first

      public static <A> Maybe<A> first(Maybe<A> x, Maybe<A> y)