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

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

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

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

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

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

  <p class="x2mdx-ref-summary">DA.Action.State.Class</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.Class</dd>
    </div>

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

## Typeclasses

<span id="class-da-action-state-class-actionstate-80467" />

### `class ActionState s m`

Action `m` has a state variable of type `s`.

Rules:

* `get *> ma  =  ma`
* `ma <* get  =  ma`
* `put a >>= get   =  put a $> a`
* `put a *> put b  =  put b`
* `(,) <$> get <*> get  =  get <&> \a -> (a, a)`

Informally, these rules mean it behaves like an ordinary assignable variable:
it doesn't magically change value by looking at it, if you put a value there
that's always the value you'll get if you read it, assigning a value but
never reading that value has no effect, and so on.

Methods:

* `get` : `m` `s`
  Fetch the current value of the state variable.
* `put` : `s` -> `m` ()
  Set the value of the state variable.
* `modify` : (`s` -> `s`) -> `m` ()
  Modify the state variable with the given function.
* `modify` : [`Action`](/appdev/reference/daml-standard-library/prelude#class-da-internal-prelude-action-68790) `m` => (`s` -> `s`) -> `m` ()

Instances:

* instance [`ActionState`](#class-da-action-state-class-actionstate-80467) `s` ([`State`](/appdev/reference/daml-standard-library/da-action-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>
