purescript / purescript-record

Functions for working with records and polymorphic labels
BSD 3-Clause "New" or "Revised" License
70 stars 31 forks source link

Add new and run to Record.ST #68

Closed kl0tl closed 3 years ago

kl0tl commented 3 years ago

Foreign.Object.ST and Data.Array.ST export means of creating empty mutable structures without having to thaw an immutable one. Should we also export new :: forall h. ST h (STRecord h ()) from Record.ST for consistency?

There’s also Foreign.Object.runST and Data.Array.ST.run to avoid copying the mutable structure in the end. Any reason not to add a similar run :: forall r. (forall h. ST h (STRecord h r)) -> Record r to Record.ST? This would require an unsafeFreeze :: forall h r. STRecord h r -> ST h (Record r) function that we could export with an unsafeThaw :: forall h r. Record r -> ST h (STRecord h r) function from a new Record.ST.Unsafe module.

MonoidMusician commented 3 years ago

Do you mean new :: forall h. ST h (STRecord h ()) (with an empty row)?

kl0tl commented 3 years ago

Oh yes, sorry about that, I wrote ST h (STRecord h r) too many times to notice anymore 🙃