2 ms·
Haskell absolutely allows mutable references and arrays. See IORef [1] and MVector [2]. Notice how the functions that perform mutation are monadic. That's Ha
by mightybyte 11y ago
Haskell absolutely allows mutable references and arrays. See IORef [1] and MVector [2]. Notice how the functions that perform mutation are monadic. That's Haskell controlling the side effects and making sure that they don't pollute pure code. The ST monad stuff [3] that wyager mentioned is even cooler because it allows you to bundle up side effecting stuff and actually use it in pure code in a completely safe way, which is something that you can't do (without the dubious usafePerformIO) with the IO monad.
[1] https://downloads.haskell.org/~ghc/latest/docs/html/libraries/base-4.8.1.0/Data-IORef.html https://downloads.haskell.org/~ghc/latest/docs/html/librarie...
[2] http://hackage.haskell.org/package/vector-0.11.0.0/docs/Data-Vector-Mutable.html#g:10 http://hackage.haskell.org/package/vector-0.11.0.0/docs/Data...
[3] https://downloads.haskell.org/~ghc/latest/docs/html/libraries/base-4.8.1.0/Control-Monad-ST.html https://downloads.haskell.org/~ghc/latest/docs/html/librarie...