2 ms·
Haskell actually does allow mutability in pure code using the ST monad. It's pretty cool; you can use ST to have mutable variables and arrays and such, but the
by wyager 11y ago
Haskell actually does allow mutability in pure code using the ST monad.
It's pretty cool; you can use ST to have mutable variables and arrays and such, but the mutable values aren't allowed to escape the ST "context". So you're still guaranteed immutability outside of the ST monad, because the type system locks all mutable values inside the monad.
This is mostly only used in very-high-performance libraries that use algorithms based on array access.