gets method

State<S, A> gets(
  1. A f(
    1. S state
    )
)

Change the value getter based on the current state S.

Implementation

State<S, A> gets(A Function(S state) f) =>
    State((state) => (f(state), state));