Module

Record.Builder

#Builder

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 Category instance for Builder can be used to compose builders.

For example:

build (insert x 42 >>> insert y "testing") {} :: { x :: Int, y :: String }

Instances

#build

build :: forall r1 r2. Builder ({  | r1 }) ({  | r2 }) -> {  | r1 } -> {  | r2 }

Build a record, starting from some other record.

#insert

insert :: forall l a r1 r2. Cons l a r1 r2 => Lacks l r1 => IsSymbol l => SProxy l -> a -> Builder ({  | r1 }) ({  | r2 })

Build by inserting a new field.

#modify

modify :: forall l a b r r1 r2. Cons l a r r1 => Cons l b r r2 => IsSymbol l => SProxy l -> (a -> b) -> Builder ({  | r1 }) ({  | r2 })

Build by modifying an existing field.

#delete

delete :: forall l a r1 r2. IsSymbol l => Lacks l r1 => Cons l a r1 r2 => SProxy l -> Builder ({  | r2 }) ({  | r1 })

Build by deleting an existing field.

#rename

rename :: forall l1 l2 a r1 r2 r3. IsSymbol l1 => IsSymbol l2 => Cons l1 a r2 r1 => Lacks l1 r2 => Cons l2 a r2 r3 => Lacks l2 r2 => SProxy l1 -> SProxy l2 -> Builder ({  | r1 }) ({  | r3 })

Build by renaming an existing field.

#merge

merge :: forall r1 r2 r3 r4. Union r1 r2 r3 => Nub r3 r4 => {  | r2 } -> Builder ({  | r1 }) ({  | r4 })

Build by merging existing fields from another record.

#union

union :: forall r1 r2 r3. Union r1 r2 r3 => {  | r2 } -> Builder ({  | r1 }) ({  | 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.

#disjointUnion

disjointUnion :: forall r1 r2 r3. Union r1 r2 r3 => Nub r3 r3 => {  | r1 } -> Builder ({  | r2 }) ({  | r3 })

Build by merging some disjoint set of fields from another record.

#nub

nub :: forall r1 r2. Nub r1 r2 => Builder ({  | r1 }) ({  | r2 })

A coercion which removes duplicate labels from a record's type.

Modules