Module

Data.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 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 Source

build :: forall r2 r1. Builder (Record r1) (Record r2) -> Record r1 -> Record r2

Build a record, starting from some other record.

#insert Source

insert :: forall r2 r1 a l. RowCons l a r1 r2 => RowLacks l r1 => IsSymbol l => SProxy l -> a -> Builder (Record r1) (Record r2)

Build by inserting a new field.

#modify Source

modify :: forall r2 r1 r b a l. RowCons l a r r1 => RowCons l b r r2 => IsSymbol l => SProxy l -> (a -> b) -> Builder (Record r1) (Record r2)

Build by modifying an existing field.

#delete Source

delete :: forall r2 r1 a l. IsSymbol l => RowLacks l r1 => RowCons l a r1 r2 => SProxy l -> Builder (Record r2) (Record r1)

Build by deleting an existing field.

#rename Source

rename :: forall r3 r2 r1 a l2 l1. IsSymbol l1 => IsSymbol l2 => RowCons l1 a r2 r1 => RowLacks l1 r2 => RowCons l2 a r2 r3 => RowLacks l2 r2 => SProxy l1 -> SProxy l2 -> Builder (Record r1) (Record r3)

Build by renaming an existing field.

#merge Source

merge :: forall r3 r2 r1. Union r1 r2 r3 => Record r2 -> Builder (Record r1) (Record r3)

Build by merging existing fields from another record.