3 ms·
This is not true, Haskell of course allows you to mutate state. It just forces you to declare it: For example, there's a MutableByteArray type whose operations
by poorlyknit 4y ago
This is not true, Haskell of course allows you to mutate state. It just forces you to declare it: For example, there's a MutableByteArray type whose operations only work in a specific Monad (because Haskell...) [1].
There's also more basic stuff like IORef which represents an assignable variable [2]. Again, you're constrained to use this in IO contexts.
Etc.
Haskell basically just forces you to do that thing someone else in this thread mentioned: Write functional APIs, allow side effects but make them explicit and confined to very specific places.
[1]: https://hackage.haskell.org/package/primitive-0.7.4.0/docs/src/Data.Primitive.ByteArray.html#newByteArray https://hackage.haskell.org/package/primitive-0.7.4.0/docs/s...
[2]: https://hackage.haskell.org/package/base-4.16.3.0/docs/Data-IORef.html https://hackage.haskell.org/package/base-4.16.3.0/docs/Data-...