Skip to main content

DA.Record

Exports the record machinery necessary to allow one to annotate code that is polymorphic in the underlying record type.

Module Snapshot

Lifecycle

Stable.

Notices

Status: active Introduced in: 3.4.9 Removed in: - Warnings: 0 Deprecations: 0 Deprecated since: -

Data Types

type HasField x r a

= (GetField x r a, SetField 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:
For more on Record syntax, see 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:
Then we get, for free, the following GetField and SetField instances:
If we want to get a value, we can use the getField method of class GetField:
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:

Typeclasses

class GetField x r a

GetField x r a provides the getter part of HasField Methods:
  • getField : r -> a
Instances:

class SetField x r a

SetField x r a provides the setter part of HasField Methods:
  • setField : a -> r -> r
Instances: