Class FromLeft


  • public class FromLeft
    extends PrimitiveFunction
    Extract the Left value from an Either, or return a default value.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Name NAME  
    • 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>
      A
      apply​(A defaultValue, Either<A,​B> either)
      Deprecated.
      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.
      protected java.util.function.Function<java.util.List<Term>,​java.util.function.Function<InferenceContext,​java.util.function.Function<Graph,​Either<Error_,​Term>>>> implementation()
      A dynamic/interpreted implementation of the function.
      protected java.util.List<java.lang.Integer> lazyParams()
      The 0-based positions of value parameters that must be passed lazily (thunked) at call sites in hosts that distinguish strict from lazy evaluation (issue #391).
      Name name()
      The unique name of the primitive function.
      TypeScheme type()
      The datatype of the primitive function.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NAME

        public static final Name NAME
    • Constructor Detail

      • FromLeft

        public FromLeft()
    • Method Detail

      • name

        public Name name()
        Description copied from class: PrimitiveFunction
        The unique name of the primitive function.
        Specified by:
        name in class PrimitiveFunction
        Returns:
        the name of this primitive function
      • lazyParams

        protected java.util.List<java.lang.Integer> lazyParams()
        Description copied from class: PrimitiveFunction
        The 0-based positions of value parameters that must be passed lazily (thunked) at call sites in hosts that distinguish strict from lazy evaluation (issue #391). Defaults to none; lazy primitives (e.g. maybes.cases, logic.ifElse) override this. Mirrors Hydra.Dsl.Prims.lazyArgs on the Haskell host, which is the source of truth for the laziness metadata.
        Overrides:
        lazyParams in class PrimitiveFunction
        Returns:
        the lazy parameter positions
      • implementation

        protected java.util.function.Function<java.util.List<Term>,​java.util.function.Function<InferenceContext,​java.util.function.Function<Graph,​Either<Error_,​Term>>>> implementation()
        Description copied from class: PrimitiveFunction
        A dynamic/interpreted implementation of the function. Subclasses implement this with Either-based logic.
        Specified by:
        implementation in class PrimitiveFunction
        Returns:
        the function implementation
      • apply

        @Deprecated
        public static <A,​B> A apply​(A defaultValue,
                                          Either<A,​B> either)
        Deprecated.
        Use applyLazy(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.