Package com.io7m.smfj.core
Class SMFPartial<A>
- java.lang.Object
-
- com.io7m.smfj.core.SMFPartial<A>
-
- Type Parameters:
A- The type of result values.
public final class SMFPartial<A> extends java.lang.ObjectThe result of evaluating a partial function.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)static <A> SMFPartial<A>failed()Fail an operation.<B> SMFPartial<B>flatMap(java.util.function.Function<A,SMFPartial<B>> f)Monadic bind for partials.Aget()inthashCode()booleanisFailed()booleanisSucceeded()<B> SMFPartial<B>map(java.util.function.Function<A,B> f)Functor map for partials.static <A> SMFPartial<A>succeeded(A inValue)Succeed an operation.
-
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.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:
trueif the operation failed
-
isSucceeded
public boolean isSucceeded()
- Returns:
trueif 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
-
-