Package fj.parser

Class Result<I,A>

java.lang.Object
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).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final A
     
    private final I
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Result(I i, A a)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <B, J> F<F<I,J>,F<F<A,B>,Result<J,B>>>
    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.
    final boolean
    equals(Object other)
     
    final int
     
    Returns an iterator over the parse value.
    <J> F<F<I,J>,Result<J,A>>
    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>>
    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.
    The remainder of the parse input.
    static <A, I> F<I,F<A,Result<I,A>>>
    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.
    final String
     
    The parsed value.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • i

      private final I i
    • a

      private final A a
  • Constructor Details

    • Result

      private Result(I i, A a)
  • Method Details

    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • equals

      public final boolean equals(Object other)
      Overrides:
      equals in class 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 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<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.
    • 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.