Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Immutable to Mutable Record type

$
0
0

Is there a way to convert a record type to mutable or read only without having to type it all again? Kind of like ReadOnly in TS, or the opposite way.

module Person = {
  type t = {name: string, age: int}
  type mut = {mutable name: string, mutable age: int}

  module Automerge = {
    type doc = Automerge.Document.t<t, mut>
  }
}

For context, I’m experimenting with some typed automerge binds.

Alternatively, is there some way to ensure the records are the same or compatible? Can a mutable record be cast with :> to the immutable version or something like that?


Viewing all articles
Browse latest Browse all 2592

Trending Articles