Interface State<T,S>

Type Parameters:
T - value type
S - state type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface State<T,S>
State monad.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(S state)
    State monad is just function S -> (T, S)
    default <R> State<R,S>
    flatMap(Function<? super T,State<R,S>> mapper)
     
    default <R> State<R,S>
    map(Function<? super T,? extends R> mapper)
     
    static <T, S> State<T,S>
    pure(T t)
    Creates state monad from pure value
  • Method Details

    • apply

      Tuple<T,S> apply(S state)
      State monad is just function S -> (T, S)
      Parameters:
      state -
      Returns:
    • pure

      static <T, S> State<T,S> pure(T t)
      Creates state monad from pure value
      Type Parameters:
      T - value type
      S - state type
      Parameters:
      t - value
      Returns:
      state monad
    • map

      default <R> State<R,S> map(Function<? super T,? extends R> mapper)
    • flatMap

      default <R> State<R,S> flatMap(Function<? super T,State<R,S>> mapper)