Re:Flix – A powerful effect-oriented programming language
by reddit_clone on Thursday July 10, 2025 @03:23PM
(#44524573)
This sounds very nice!
Re:Flix – A powerful effect-oriented programming language
by sparkie on Thursday July 10, 2025 @10:32PM
(#44527915)
Haskell can do the same kind of thing (local mutation), using the ST monad.
It's usage is almost equivalent to using IORefs, except we can escape ST using runST to get back a pure value not in ST, which we cannot do for IO because there is no `IO a -> a`.
There's no requirement to contain ST to a single function - we can split mutation over several functions, provided each one involved returns some `ST a` and their usage is combined with >>=.
Re:Flix – A powerful effect-oriented programming language
by jorkadeen on Friday July 11, 2025 @03:23AM
(#44529263)
That's right. Locally scoped mutable memory in Flix is very similar to the ST Monad. The two major differences are: (a) Flix is in direct-style vs. monadic style and (b) we use a type and effect system.
Note that there is no requirement that all mutation must occur within a single function. The requirement is that once you leave the lexical scope then all mutable memory associated with that scope become unreachable. Mutation can certainly span over multiple functions.
Re:Flix – A powerful effect-oriented programming language
by exceptione on Saturday July 12, 2025 @05:11AM
(#44540543)
What do you mean with 'cannot'? We have this in [0]
unsafePerformIO :: IO a -> a
Do you mean "cannot do with safety guarantee"? Strangely enough, the haskell docs use the same language as you: The ST monad allows for destructive updates, but is escapable (unlike IO).
___0. https://hackage.haskell.org/package/base-4.21.0.0/docs/Syste...
(I am one of the developers of Flix)