Package hydra.lib.eithers
Class FromLeft
- java.lang.Object
-
- hydra.tools.PrimitiveFunction
-
- hydra.lib.eithers.FromLeft
-
public class FromLeft extends PrimitiveFunction
Extract the Left value from an Either, or return a default value.
-
-
Constructor Summary
Constructors Constructor Description FromLeft()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <A,B>
Aapply(A defaultValue, Either<A,B> either)Deprecated.UseapplyLazy(Supplier, Either)instead.static <A,B>
AapplyLazy(java.util.function.Supplier<A> defaultValue, Either<A,B> either)Lazily extract the Left value from an Either, or return a default value if it is a Right.protected java.util.function.Function<java.util.List<Term>,java.util.function.Function<Context,java.util.function.Function<Graph,Either<InContext<Error_>,Term>>>>implementation()A dynamic/interpreted implementation of the function.Namename()The unique name of the primitive function.TypeSchemetype()The datatype of the primitive function.-
Methods inherited from class hydra.tools.PrimitiveFunction
term, toNative
-
-
-
-
Field Detail
-
NAME
public static final Name NAME
-
-
Method Detail
-
name
public Name name()
Description copied from class:PrimitiveFunctionThe unique name of the primitive function.- Specified by:
namein classPrimitiveFunction- Returns:
- the name of this primitive function
-
type
public TypeScheme type()
Description copied from class:PrimitiveFunctionThe datatype of the primitive function.- Specified by:
typein classPrimitiveFunction- Returns:
- the type scheme of this primitive function
-
implementation
protected java.util.function.Function<java.util.List<Term>,java.util.function.Function<Context,java.util.function.Function<Graph,Either<InContext<Error_>,Term>>>> implementation()
Description copied from class:PrimitiveFunctionA dynamic/interpreted implementation of the function. Subclasses implement this with Either-based logic.- Specified by:
implementationin classPrimitiveFunction- Returns:
- the function implementation
-
apply
@Deprecated public static <A,B> A apply(A defaultValue, Either<A,B> either)Deprecated.UseapplyLazy(Supplier, Either)instead. Eager evaluation of the default wastes memory.
-
applyLazy
public static <A,B> A applyLazy(java.util.function.Supplier<A> defaultValue, Either<A,B> either)Lazily extract the Left value from an Either, or return a default value if it is a Right. The default is only evaluated if the Either is a Right.
-
-