Package fj.parser
Class Result<I,A>
- java.lang.Object
-
- fj.parser.Result<I,A>
-
- All Implemented Interfaces:
java.lang.Iterable<A>
public final class Result<I,A> extends java.lang.Object implements java.lang.Iterable<A>
A parse result made up of a value (A) and the remainder of the parse input (I).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <B,J>
F<F<I,J>,F<F<A,B>,Result<J,B>>>bimap()
First-class bifunctor map.<B,J>
Result<J,B>bimap(F<I,J> f, F<A,B> g)
A bifunctor map across both the remainder of the parse input and the parse value.boolean
equals(java.lang.Object other)
int
hashCode()
java.util.Iterator<A>
iterator()
Returns an iterator over the parse value.<J> F<F<I,J>,Result<J,A>>
mapRest()
First-class function mapping across the remainder of the parse input.<J> Result<J,A>
mapRest(F<I,J> f)
Maps the given function across the remainder of the parse input.<B> F<F<A,B>,Result<I,B>>
mapValue()
First-class function mapping across the parse value.<B> Result<I,B>
mapValue(F<A,B> f)
Maps the given function across the parse value.I
rest()
The remainder of the parse input.static <A,I>
F<I,F<A,Result<I,A>>>result()
First-class construction of a result.static <A,I>
Result<I,A>result(I i, A a)
Construct a result with the given remainder of the parse input and parse value.java.lang.String
toString()
A
value()
The parsed value.
-
-
-
Method Detail
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
rest
public I rest()
The remainder of the parse input.- Returns:
- The remainder of the parse input.
-
value
public A value()
The parsed value.- Returns:
- The parsed value.
-
mapRest
public <J> Result<J,A> mapRest(F<I,J> f)
Maps the given function across the remainder of the parse input.- Parameters:
f
- The function to map with.- Returns:
- A result with a different parse input.
-
mapRest
public <J> F<F<I,J>,Result<J,A>> mapRest()
First-class function mapping across the remainder of the parse input.- Returns:
- A first-class function mapping across the remainder of the parse input.
-
mapValue
public <B> Result<I,B> mapValue(F<A,B> f)
Maps the given function across the parse value.- Parameters:
f
- The function to map with.- Returns:
- A result with a different parse value.
-
mapValue
public <B> F<F<A,B>,Result<I,B>> mapValue()
First-class function mapping across the parse value.- Returns:
- A first-class function mapping across the parse value.
-
bimap
public <B,J> Result<J,B> bimap(F<I,J> f, F<A,B> g)
A bifunctor map across both the remainder of the parse input and the parse value.- Parameters:
f
- The function to map the remainder of the parse input with.g
- The function to map the parse value with.- Returns:
- A result with a different parse input and parse value.
-
bimap
public <B,J> F<F<I,J>,F<F<A,B>,Result<J,B>>> bimap()
First-class bifunctor map.- Returns:
- A first-class bifunctor map.
-
iterator
public java.util.Iterator<A> iterator()
Returns an iterator over the parse value. This method exists to permit the use in afor
-each loop.- Specified by:
iterator
in interfacejava.lang.Iterable<I>
- Returns:
- An iterator over the parse value.
-
result
public static <A,I> Result<I,A> result(I i, A a)
Construct a result with the given remainder of the parse input and parse value.- Parameters:
i
- The remainder of the parse input.a
- The parse value.- Returns:
- A result with the given remainder of the parse input and parse value.
-
-