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

> Reference documentation for Daml module DA.Record.

Daml module

# DA.Record

Exports the record machinery necessary to allow one to annotate

Daml

Module
DA.Record

Latest release
3.7.5

## Data Types

### `type HasField x r a`

\= ([`GetField`](#class-da-internal-record-getfield-53979) `x` `r` `a`, [`SetField`](#class-da-internal-record-setfield-4311) `x` `r` `a`)

`HasField` is a class synonym for `GetField` and `SetField`, which
respectively give you getter and setter functions for each record field
automatically.

**In the vast majority of use-cases, plain Record syntax should be
preferred**:

```
daml> let a = MyRecord 1 "hello"
daml> a.foo
1
daml> a.bar
"hello"
daml> a { bar = "bye" }
MyRecord {foo = 1, bar = "bye"}
daml> a with foo = 3
MyRecord {foo = 3, bar = "hello"}
daml>
```

For more on Record syntax, see [https://docs.digitalasset.com/build/3.4/reference/daml/stdlib/DA-Record.html](https://docs.digitalasset.com/build/3.4/reference/daml/stdlib/DA-Record.html).

`GetField x r a` and `SetField x r a` are typeclasses taking three parameters. The first
parameter `x` is the field name, the second parameter `r` is the record type,
and the last parameter `a` is the type of the field in this record. For
example, if we define a type:

```
data MyRecord = MyRecord with
    foo : Int
    bar : Text
```

Then we get, for free, the following GetField and SetField instances:

```
GetField "foo" MyRecord Int
SetField "foo" MyRecord Int
GetField "bar" MyRecord Text
SetField "bar" MyRecord Text
```

If we want to get a value, we can use the `getField` method of class `GetField`:

```
getFoo : MyRecord -> Int
getFoo r = getField @"foo" r

getBar : MyRecord -> Text
getBar r = getField @"bar" r
```

Note that this uses the “type application” syntax ( `f @t` ) to specify the
field name.

Likewise, if we want to set the value in the field, we can use the `setField` method of class `SetField`:

```
setFoo : Int -> MyRecord -> MyRecord
setFoo a r = setField @"foo" a r

setBar : Text -> MyRecord -> MyRecord
setBar a r = setField @"bar" a r
```

## Typeclasses

### `class GetField x r a`

`GetField x r a` provides the getter part of `HasField`

Methods:

* `getField` : `r` -> `a`

Instances:

* instance [`GetField`](#class-da-internal-record-getfield-53979) `_1` (`a`, `b`) `a`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_1` (`a`, `b`, `c`) `a`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_1` (`a`, `b`, `c`, `d`) `a`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_1` (`a`, `b`, `c`, `d`, `e`) `a`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_2` (`a`, `b`) `b`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_2` (`a`, `b`, `c`) `b`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_2` (`a`, `b`, `c`, `d`) `b`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_2` (`a`, `b`, `c`, `d`, `e`) `b`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_3` (`a`, `b`, `c`) `c`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_3` (`a`, `b`, `c`, `d`) `c`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_3` (`a`, `b`, `c`, `d`, `e`) `c`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_4` (`a`, `b`, `c`, `d`) `d`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_4` (`a`, `b`, `c`, `d`, `e`) `d`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `_5` (`a`, `b`, `c`, `d`, `e`) `e`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `appEndo` ([`Endo`](https://docs.canton.network/appdev/reference/daml-standard-library/da-monoid#type-da-monoid-types-endo-95420) `a`) (`a` -> `a`)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `category` [`FailureStatus`](https://docs.canton.network/appdev/reference/daml-standard-library/da-fail#type-da-internal-fail-types-failurestatus-69615) [`FailureCategory`](https://docs.canton.network/appdev/reference/daml-standard-library/da-fail#type-da-internal-fail-types-failurecategory-97811)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `errorId` [`FailureStatus`](https://docs.canton.network/appdev/reference/daml-standard-library/da-fail#type-da-internal-fail-types-failurestatus-69615) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `getAll` [`All`](https://docs.canton.network/appdev/reference/daml-standard-library/da-monoid#type-da-monoid-types-all-38142) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `getAny` [`Any`](https://docs.canton.network/appdev/reference/daml-standard-library/da-monoid#type-da-monoid-types-any-3989) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `getAnyView` [`AnyView`](https://docs.canton.network/appdev/reference/daml-standard-library/da-internal-interface-anyview-types#type-da-internal-interface-anyview-types-anyview-16883) `Any`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `getAnyViewInterfaceTypeRep` [`AnyView`](https://docs.canton.network/appdev/reference/daml-standard-library/da-internal-interface-anyview-types#type-da-internal-interface-anyview-types-anyview-16883) [`InterfaceTypeRep`](https://docs.canton.network/appdev/reference/daml-standard-library/da-internal-interface-anyview-types#type-da-internal-interface-anyview-types-interfacetyperep-5047)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `hd` ([`NonEmpty`](https://docs.canton.network/appdev/reference/daml-standard-library/da-nonempty-types#type-da-nonempty-types-nonempty-16010) `a`) `a`
* instance [`GetField`](#class-da-internal-record-getfield-53979) `map` ([`Set`](https://docs.canton.network/appdev/reference/daml-standard-library/da-set#type-da-set-types-set-90436) `k`) ([`Map`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-map-90052) `k` ())
* instance [`GetField`](#class-da-internal-record-getfield-53979) `message` [`FailureStatus`](https://docs.canton.network/appdev/reference/daml-standard-library/da-fail#type-da-internal-fail-types-failurestatus-69615) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `message` [`ArithmeticError`](https://docs.canton.network/appdev/reference/daml-standard-library/da-exception#type-da-exception-arithmeticerror-arithmeticerror-68828) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `message` [`AssertionFailed`](https://docs.canton.network/appdev/reference/daml-standard-library/da-exception#type-da-exception-assertionfailed-assertionfailed-69740) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `message` [`GeneralError`](https://docs.canton.network/appdev/reference/daml-standard-library/da-exception#type-da-exception-generalerror-generalerror-5800) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `message` [`PreconditionFailed`](https://docs.canton.network/appdev/reference/daml-standard-library/da-exception#type-da-exception-preconditionfailed-preconditionfailed-61218) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `meta` [`FailureStatus`](https://docs.canton.network/appdev/reference/daml-standard-library/da-fail#type-da-internal-fail-types-failurestatus-69615) ([`TextMap`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-textmap-11691) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952))
* instance [`GetField`](#class-da-internal-record-getfield-53979) `runState` ([`State`](https://docs.canton.network/appdev/reference/daml-standard-library/da-action-state#type-da-action-state-type-state-76783) `s` `a`) (`s` -> (`a`, `s`))
* instance [`GetField`](#class-da-internal-record-getfield-53979) `srcLocEndCol` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `srcLocEndLine` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `srcLocFile` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `srcLocModule` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `srcLocPackage` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `srcLocStartCol` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `srcLocStartLine` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)
* instance [`GetField`](#class-da-internal-record-getfield-53979) `tl` ([`NonEmpty`](https://docs.canton.network/appdev/reference/daml-standard-library/da-nonempty-types#type-da-nonempty-types-nonempty-16010) `a`) \[`a`]

### `class SetField x r a`

`SetField x r a` provides the setter part of `HasField`

Methods:

* `setField` : `a` -> `r` -> `r`

Instances:

* instance [`SetField`](#class-da-internal-record-setfield-4311) `_1` (`a`, `b`) `a`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_1` (`a`, `b`, `c`) `a`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_1` (`a`, `b`, `c`, `d`) `a`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_1` (`a`, `b`, `c`, `d`, `e`) `a`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_2` (`a`, `b`) `b`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_2` (`a`, `b`, `c`) `b`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_2` (`a`, `b`, `c`, `d`) `b`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_2` (`a`, `b`, `c`, `d`, `e`) `b`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_3` (`a`, `b`, `c`) `c`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_3` (`a`, `b`, `c`, `d`) `c`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_3` (`a`, `b`, `c`, `d`, `e`) `c`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_4` (`a`, `b`, `c`, `d`) `d`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_4` (`a`, `b`, `c`, `d`, `e`) `d`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `_5` (`a`, `b`, `c`, `d`, `e`) `e`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `appEndo` ([`Endo`](https://docs.canton.network/appdev/reference/daml-standard-library/da-monoid#type-da-monoid-types-endo-95420) `a`) (`a` -> `a`)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `category` [`FailureStatus`](https://docs.canton.network/appdev/reference/daml-standard-library/da-fail#type-da-internal-fail-types-failurestatus-69615) [`FailureCategory`](https://docs.canton.network/appdev/reference/daml-standard-library/da-fail#type-da-internal-fail-types-failurecategory-97811)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `errorId` [`FailureStatus`](https://docs.canton.network/appdev/reference/daml-standard-library/da-fail#type-da-internal-fail-types-failurestatus-69615) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `getAll` [`All`](https://docs.canton.network/appdev/reference/daml-standard-library/da-monoid#type-da-monoid-types-all-38142) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `getAny` [`Any`](https://docs.canton.network/appdev/reference/daml-standard-library/da-monoid#type-da-monoid-types-any-3989) [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `getAnyView` [`AnyView`](https://docs.canton.network/appdev/reference/daml-standard-library/da-internal-interface-anyview-types#type-da-internal-interface-anyview-types-anyview-16883) `Any`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `getAnyViewInterfaceTypeRep` [`AnyView`](https://docs.canton.network/appdev/reference/daml-standard-library/da-internal-interface-anyview-types#type-da-internal-interface-anyview-types-anyview-16883) [`InterfaceTypeRep`](https://docs.canton.network/appdev/reference/daml-standard-library/da-internal-interface-anyview-types#type-da-internal-interface-anyview-types-interfacetyperep-5047)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `hd` ([`NonEmpty`](https://docs.canton.network/appdev/reference/daml-standard-library/da-nonempty-types#type-da-nonempty-types-nonempty-16010) `a`) `a`
* instance [`SetField`](#class-da-internal-record-setfield-4311) `map` ([`Set`](https://docs.canton.network/appdev/reference/daml-standard-library/da-set#type-da-set-types-set-90436) `k`) ([`Map`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-map-90052) `k` ())
* instance [`SetField`](#class-da-internal-record-setfield-4311) `message` [`FailureStatus`](https://docs.canton.network/appdev/reference/daml-standard-library/da-fail#type-da-internal-fail-types-failurestatus-69615) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `message` [`ArithmeticError`](https://docs.canton.network/appdev/reference/daml-standard-library/da-exception#type-da-exception-arithmeticerror-arithmeticerror-68828) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `message` [`AssertionFailed`](https://docs.canton.network/appdev/reference/daml-standard-library/da-exception#type-da-exception-assertionfailed-assertionfailed-69740) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `message` [`GeneralError`](https://docs.canton.network/appdev/reference/daml-standard-library/da-exception#type-da-exception-generalerror-generalerror-5800) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `message` [`PreconditionFailed`](https://docs.canton.network/appdev/reference/daml-standard-library/da-exception#type-da-exception-preconditionfailed-preconditionfailed-61218) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `meta` [`FailureStatus`](https://docs.canton.network/appdev/reference/daml-standard-library/da-fail#type-da-internal-fail-types-failurestatus-69615) ([`TextMap`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-textmap-11691) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952))
* instance [`SetField`](#class-da-internal-record-setfield-4311) `runState` ([`State`](https://docs.canton.network/appdev/reference/daml-standard-library/da-action-state#type-da-action-state-type-state-76783) `s` `a`) (`s` -> (`a`, `s`))
* instance [`SetField`](#class-da-internal-record-setfield-4311) `srcLocEndCol` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `srcLocEndLine` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `srcLocFile` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `srcLocModule` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `srcLocPackage` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Text`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `srcLocStartCol` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `srcLocStartLine` [`SrcLoc`](https://docs.canton.network/appdev/reference/daml-standard-library/da-stack#type-da-stack-types-srcloc-15887) [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)
* instance [`SetField`](#class-da-internal-record-setfield-4311) `tl` ([`NonEmpty`](https://docs.canton.network/appdev/reference/daml-standard-library/da-nonempty-types#type-da-nonempty-types-nonempty-16010) `a`) \[`a`]
