Class MaxWith<A>
- java.lang.Object
-
- com.jnape.palatable.lambda.semigroup.builtin.MaxWith<A>
-
- Type Parameters:
A
- the value type
- All Implemented Interfaces:
Fn1<java.util.Comparator<A>,Fn1<A,Fn1<A,A>>>
,Fn2<java.util.Comparator<A>,A,Fn1<A,A>>
,Fn3<java.util.Comparator<A>,A,A,A>
,SemigroupFactory<java.util.Comparator<A>,A>
,Applicative<Fn1<A,Fn1<A,A>>,Fn1<java.util.Comparator<A>,?>>
,Cartesian<java.util.Comparator<A>,Fn1<A,Fn1<A,A>>,Fn1<?,?>>
,Cocartesian<java.util.Comparator<A>,Fn1<A,Fn1<A,A>>,Fn1<?,?>>
,Contravariant<java.util.Comparator<A>,Profunctor<?,Fn1<A,Fn1<A,A>>,Fn1<?,?>>>
,Functor<Fn1<A,Fn1<A,A>>,Fn1<java.util.Comparator<A>,?>>
,Profunctor<java.util.Comparator<A>,Fn1<A,Fn1<A,A>>,Fn1<?,?>>
,Monad<Fn1<A,Fn1<A,A>>,Fn1<java.util.Comparator<A>,?>>
,MonadReader<java.util.Comparator<A>,Fn1<A,Fn1<A,A>>,Fn1<java.util.Comparator<A>,?>>
,MonadRec<Fn1<A,Fn1<A,A>>,Fn1<java.util.Comparator<A>,?>>
,MonadWriter<java.util.Comparator<A>,Fn1<A,Fn1<A,A>>,Fn1<java.util.Comparator<A>,?>>
public final class MaxWith<A> extends java.lang.Object implements SemigroupFactory<java.util.Comparator<A>,A>
Given a comparator for some typeA
, produce aSemigroup
overA
that chooses between two valuesx
andy
via the following rules:- If
x
is strictly less thany
in terms ofB
, returny
- Otherwise, return
x
-
-
Constructor Summary
Constructors Modifier Constructor Description private
MaxWith()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Semigroup<A>
checkedApply(java.util.Comparator<A> comparator)
Invoke this function with the given argument, potentially throwing anyThrowable
.static <A> MaxWith<A>
maxWith()
static <A> Semigroup<A>
maxWith(java.util.Comparator<A> compareFn)
static <A> Fn1<A,A>
maxWith(java.util.Comparator<A> compareFn, A x)
static <A> A
maxWith(java.util.Comparator<A> compareFn, A x, A y)
-
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
toBiFunction
-
Methods inherited from interface com.jnape.palatable.lambda.functions.Fn3
apply, apply, checkedApply, compose, contraMap, diMapL, discardR, flip, uncurry, widen
-
Methods inherited from interface com.jnape.palatable.lambda.functions.specialized.SemigroupFactory
apply, checkedApply
-
-
-
-
Field Detail
-
INSTANCE
private static final MaxWith<?> INSTANCE
-
-
Method Detail
-
maxWith
public static <A> MaxWith<A> maxWith()
-
maxWith
public static <A> Semigroup<A> maxWith(java.util.Comparator<A> compareFn)
-
maxWith
public static <A> Fn1<A,A> maxWith(java.util.Comparator<A> compareFn, A x)
-
maxWith
public static <A> A maxWith(java.util.Comparator<A> compareFn, A x, A y)
-
checkedApply
public Semigroup<A> checkedApply(java.util.Comparator<A> comparator)
Description copied from interface:Fn2
Invoke this function with the given argument, potentially throwing anyThrowable
.- Specified by:
checkedApply
in interfaceFn1<java.util.Comparator<A>,Fn1<A,Fn1<A,A>>>
- Specified by:
checkedApply
in interfaceFn2<java.util.Comparator<A>,A,Fn1<A,A>>
- Specified by:
checkedApply
in interfaceSemigroupFactory<java.util.Comparator<A>,A>
- Parameters:
comparator
- the argument- Returns:
- the result of the function application
-
-