Module
Record.Builder
- Package
- purescript-record
- Repository
- purescript/purescript-record
#Builder Source
newtype Builder a b
A Builder
can be used to build
a record by incrementally adding
fields in-place, instead of using insert
and repeatedly generating new
immutable records which need to be garbage collected.
The mutations accumulated in a Builder
are safe because intermediate states can't be
observed. These mutations, then, are performed all-at-once in the build
function.
The Category
instance for Builder
can be used to compose builders.
For example:
build (insert x 42 >>> insert y "testing") {} :: { x :: Int, y :: String }
Instances
#union Source
union :: forall r3 r2 r1. Union r1 r2 r3 => Record r2 -> Builder (Record r1) (Record r3)
Build by merging existing fields from another record. Unlike merge
,
this does not remove duplicate labels from the resulting record type.
This can result in better inference for some pipelines, deferring the
need for a Nub
constraint.