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

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

Daml module

# DA.Action.State.Class

DA.Action.State.Class

Daml

Module
DA.Action.State.Class

Latest release
3.7.5

## Typeclasses

### `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`](https://docs.canton.network/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`](https://docs.canton.network/appdev/reference/daml-standard-library/da-action-state#type-da-action-state-type-state-76783) `s`)
