Class SMFPartial<A>

  • Type Parameters:
    A - The type of result values.

    public final class SMFPartial<A>
    extends java.lang.Object
    The result of evaluating a partial function.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • failed

        public static <A> SMFPartial<A> failed()
        Fail an operation.
        Type Parameters:
        A - The type of result values
        Returns:
        A failed operation
      • succeeded

        public static <A> SMFPartial<A> succeeded​(A inValue)
        Succeed an operation.
        Type Parameters:
        A - The type of result values
        Parameters:
        inValue - The result of the operation
        Returns:
        A succeeded operation
      • get

        public A get()
              throws java.lang.IllegalStateException
        Returns:
        The result of the operation if it succeeded
        Throws:
        java.lang.IllegalStateException - If the operation failed
      • isFailed

        public boolean isFailed()
        Returns:
        true if the operation failed
      • isSucceeded

        public boolean isSucceeded()
        Returns:
        true if the operation succeeded
      • map

        public <B> SMFPartial<B> map​(java.util.function.Function<A,​B> f)
        Functor map for partials.
        Type Parameters:
        B - The type of mapped values
        Parameters:
        f - A function to apply to the value
        Returns:
        f(x)
      • flatMap

        public <B> SMFPartial<B> flatMap​(java.util.function.Function<A,​SMFPartial<B>> f)
        Monadic bind for partials.
        Type Parameters:
        B - The type of mapped values
        Parameters:
        f - A function to apply to the value
        Returns:
        this >>= f