Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg

This software is released under an open source BSD licence.

fj.parser
Class Result<I,A>

java.lang.Object
  extended by fj.parser.Result<I,A>
All Implemented Interfaces:
Iterable<A>

public final class Result<I,A>
extends Object
implements Iterable<A>

A parse result made up of a value (A) and the remainder of the parse input (I).


Method Summary
<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.
 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.
 A value()
          The parsed value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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 Iterator<A> iterator()
Returns an iterator over the parse value. This method exists to permit the use in a for-each loop.

Specified by:
iterator in interface Iterable<A>
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.

result

public static <A,I> F<I,F<A,Result<I,A>>> result()
First-class construction of a result.

Returns:
A first-class function for construction of a result.

Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg

This software is released under an open source BSD licence.