|
|
|
|
|
by mp8
4371 days ago
|
|
> So as I understand it,languages like Haskell(which I dont know) wrap states into a type that can be passed to pure functions right? I would restate this as: "In Haskell you write a description of a stateful computation." The "State Monad" is really just the illusion of mutable state, provided by passing the underlying state to each described computation. Actually-mutable state is possible with things like IORef, but these are impure. |
|
From the Haskell point of view, so called "actually-mutable" state is on the other hand deeply magical, because it lets you do exotic things like having one thread modify a value in another thread. And that's possible through things like IORefs. But it should be avoided as much as possible.