> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canton.network/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If you are building a Canton Network application, start from https://docs.canton.network/appdev/quickstart.md. To run only a local network for your own Daml code, without building the QuickStart demo, see https://docs.canton.network/sdks-tools/development-tools/localnet.md.

# DA.Action.State

> Reference documentation for Daml module DA.Action.State.

Daml module

# DA.Action.State

DA.Action.State

Daml

Module
DA.Action.State

Latest release
3.7.5

## Data Types

### `data State s a`

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
A value of type `State s a` represents a computation that has access to a state variable
of type `s` and produces a value of type `a`.

>>> runState (modify (+1)) 0
((), 1)

>>> evalState (modify (+1)) 0
()

>>> execState (modify (+1)) 0
1

>>> runState (do x <- get; modify (+1); pure x) 0
(0, 1)

>>> runState (put 1) 0
((), 1)

>>> runState (modify (+1)) 0
((), 1)

Note that values of type `State s a` are not serializable.
```

Constructors:

* `State`

**runState** `s -\> (a, s)`

Instances:

* instance [`ActionState`](https://docs.canton.network/appdev/reference/daml-standard-library/da-action-state-class#class-da-action-state-class-actionstate-80467) `s` ([`State`](#type-da-action-state-type-state-76783) `s`)
* instance [`Action`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-action-68790) ([`State`](#type-da-action-state-type-state-76783) `s`)
* instance [`Applicative`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-applicative-9257) ([`State`](#type-da-action-state-type-state-76783) `s`)
* instance [`GetField`](https://docs.canton.network/appdev/reference/daml-standard-library/da-record#class-da-internal-record-getfield-53979) `runState` ([`State`](#type-da-action-state-type-state-76783) `s` `a`) (`s` -> (`a`, `s`))
* instance [`SetField`](https://docs.canton.network/appdev/reference/daml-standard-library/da-record#class-da-internal-record-setfield-4311) `runState` ([`State`](#type-da-action-state-type-state-76783) `s` `a`) (`s` -> (`a`, `s`))
* instance [`Functor`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-base-functor-31205) ([`State`](#type-da-action-state-type-state-76783) `s`)

## Functions

### `evalState`

`evalState` : [`State`](#type-da-action-state-type-state-76783) `s` `a` -> `s` -> `a`

Special case of `runState` that does not return the final state.

### `execState`

`execState` : [`State`](#type-da-action-state-type-state-76783) `s` `a` -> `s` -> `s`

Special case of `runState` that does only retun the final state.

## Orphan Typeclass Instances

* instance [`Functor`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-base-functor-31205) ([`State`](#type-da-action-state-type-state-76783) `s`)

* instance [`Applicative`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-applicative-9257) ([`State`](#type-da-action-state-type-state-76783) `s`)

* instance [`Action`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-action-68790) ([`State`](#type-da-action-state-type-state-76783) `s`)

* instance [`ActionState`](https://docs.canton.network/appdev/reference/daml-standard-library/da-action-state-class#class-da-action-state-class-actionstate-80467) `s` ([`State`](#type-da-action-state-type-state-76783) `s`)
