> ## Documentation Index
> Fetch the complete documentation index at: https://cantonfoundation-generated-reference-full-stack-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# DA.Action.State

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

<div class="x2mdx-ref-page x2mdx-ref-page--collection" />

<span id="module-da-action-state-50232" />

<div class="x2mdx-ref-hero">
  <p class="x2mdx-ref-eyebrow">Daml module</p>

  <h1 class="x2mdx-ref-title">DA.Action.State</h1>

  <p class="x2mdx-ref-summary">DA.Action.State</p>

  <div class="x2mdx-ref-badges">
    <span class="x2mdx-ref-badge x2mdx-ref-badge--protocol">Daml</span>

    <a class="x2mdx-ref-badge x2mdx-ref-badge--added" href="#history-added-3-4-9">Added 3.4.9</a>
  </div>

  <dl class="x2mdx-ref-meta-grid">
    <div class="x2mdx-ref-meta-item">
      <dt>Module</dt>
      <dd>DA.Action.State</dd>
    </div>

    <div class="x2mdx-ref-meta-item">
      <dt>Latest release</dt>
      <dd>3.5.7</dd>
    </div>
  </dl>
</div>

## Data Types

<span id="type-da-action-state-type-state-76783" />

### `data State s a`

```text theme={null}
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:

<span id="constr-da-action-state-type-state-26" />

* `State`

<ResponseField name="runState" type="s -> (a, s)" />

Instances:

* instance [`ActionState`](/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`](/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-action-68790) ([`State`](#type-da-action-state-type-state-76783) `s`)
* instance [`Applicative`](/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-applicative-9257) ([`State`](#type-da-action-state-type-state-76783) `s`)
* instance [`GetField`](/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`](/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`](/appdev/reference/daml-standard-library/prelude#class-ghc-base-functor-31205) ([`State`](#type-da-action-state-type-state-76783) `s`)

## Functions

<span id="function-da-action-state-evalstate-95640" />

### `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.

<span id="function-da-action-state-execstate-48251" />

### `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`](/appdev/reference/daml-standard-library/prelude#class-ghc-base-functor-31205) ([`State`](#type-da-action-state-type-state-76783) `s`)

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

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

* instance [`ActionState`](/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`)

## History

<div class="x2mdx-ref-history" aria-label="Reference history">
  <div class="x2mdx-ref-history-event x2mdx-ref-history-event--introduced" id="history-added-3-4-9">
    <div class="x2mdx-ref-history-event-head">
      <span class="x2mdx-ref-history-event-label">Added</span>
      <code class="x2mdx-ref-history-event-version">3.4.9</code>
    </div>
  </div>
</div>
