# Applicative

## of

Signature

``````export declare const of: <S, A>(a: A) => State<S, A>
``````

# Apply

## ap

Apply a function to an argument under a type constructor.

Signature

``````export declare const ap: <E, A>(fa: State<E, A>) => <B>(fab: State<E, (a: A) => B>) => State<E, B>
``````

## apFirst

Combine two effectful actions, keeping only the result of the first.

Signature

``````export declare const apFirst: <E, B>(fb: State<E, B>) => <A>(fa: State<E, A>) => State<E, A>
``````

## apSecond

Combine two effectful actions, keeping only the result of the second.

Signature

``````export declare const apSecond: <E, B>(fb: State<E, B>) => <A>(fa: State<E, A>) => State<E, B>
``````

# Functor

## map

`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types use the type constructor `F` to represent some computational context.

Signature

``````export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: State<E, A>) => State<E, B>
``````

## chain

Composes computations in sequence, using the return value of one computation to determine the next computation.

Signature

``````export declare const chain: <E, A, B>(f: (a: A) => State<E, B>) => (ma: State<E, A>) => State<E, B>
``````

## chainFirst

Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.

Signature

``````export declare const chainFirst: <E, A, B>(f: (a: A) => State<E, B>) => (ma: State<E, A>) => State<E, A>
``````

## flatten

Signature

``````export declare const flatten: <E, A>(mma: State<E, State<E, A>>) => State<E, A>
``````

# constructors

## get

Get the current state

Signature

``````export declare const get: <S>() => State<S, S>
``````

## gets

Get a value which depends on the current state

Signature

``````export declare const gets: <S, A>(f: (s: S) => A) => State<S, A>
``````

## modify

Modify the state by applying a function to the current state

Signature

``````export declare const modify: <S>(f: (s: S) => S) => State<S, void>
``````

## put

Set the state

Signature

``````export declare const put: <S>(s: S) => State<S, void>
``````

# instances

## URI

Signature

``````export declare const URI: 'State'
``````

## URI (type alias)

Signature

``````export type URI = typeof URI
``````

## applicativeState

Signature

``````export declare const applicativeState: Applicative2<'State'>
``````

## functorState

Signature

``````export declare const functorState: Functor2<'State'>
``````

Signature

``````export declare const monadState: Monad2<'State'>
``````

## state

Signature

``````export declare const state: Monad2<'State'>
``````

# model

## State (interface)

Signature

``````export interface State<S, A> {
(s: S): [A, S]
}
``````

# utils

## evalState

Run a computation in the `State` monad, discarding the final state

Signature

``````export declare const evalState: <S, A>(ma: State<S, A>, s: S) => A
``````

Run a computation in the `State` monad discarding the result
``````export declare const execState: <S, A>(ma: State<S, A>, s: S) => S