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.Object
The result of evaluating a partial function.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(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.A
get()
int
hashCode()
boolean
isFailed()
boolean
isSucceeded()
<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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in 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:
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
-
-