When you update a record in OCaml does the object get reallocated

I think so. It wouldn't be clever enough to know that I no longer need the object anymore all the time and compile it to a mutation appropriately

That's why Haskell people use state monads isn't it? There must be special GHC tricks to recognize that past state is no longer live so it can therefore compile to mutating the state object

Look I really don't want to think about the efficiency of state monads in OCaml

@ionchy If you need efficiency, genuine state is always available. Also record fields can be marked mutable

@jordyd I think I will write "if you want efficiency there are solutions. don't ask me"

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!