Zulip Chat Archive

Stream: lean4

Topic: Shared mutable state


Juan Pablo Romero (Aug 06 2022 at 17:54):

Hi, Is there a way to share mutable state amongst tasks? (something like MVars in Haskell?)

Gabriel Ebner (Aug 06 2022 at 18:05):

You could abuse IO.Ref for this (which is an atomic reference) but that will busy-loop on contented accesses. If you wait a little, we'll soon have a Rust-style Mutex type for mutex-guarded shared mutable state.

Gabriel Ebner (Aug 06 2022 at 18:07):

https://github.com/gebner/lean4/blob/10983d956cca532fcd3bdd6e7cd30ee1b87532de/src/Lean/Mutex.lean

Gabriel Ebner (Aug 06 2022 at 18:08):

https://github.com/leanprover/lean4/issues/1280

Juan Pablo Romero (Aug 06 2022 at 18:08):

Nice!


Last updated: Dec 20 2023 at 11:08 UTC