Class FromLeft


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

    • NAME

      public static final Name NAME
  • Constructor Details

    • FromLeft

      public FromLeft()
  • Method Details

    • 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
    • type

      public TypeScheme type()
      Description copied from class: PrimitiveFunction
      The datatype of the primitive function.
      Specified by:
      type in class PrimitiveFunction
      Returns:
      the type scheme of this primitive function
    • implementation

      protected Function<List<Term>,Flow<Graph,Term>> implementation()
      Description copied from class: PrimitiveFunction
      A dynamic/interpreted implementation of the function.
      Specified by:
      implementation in class PrimitiveFunction
      Returns:
      the function implementation
    • apply

      public static <A, B> A apply(A defaultValue, Either<A,B> either)
      Extract the Left value from an Either, or return a default value if it is a Right.
      Type Parameters:
      A - the left type
      B - the right type
      Parameters:
      defaultValue - the default value to return if the Either is a Right
      either - the Either value to extract from
      Returns:
      the Left value or the default