3 ms·
You can think about your second version as without side-effects too. It's just in IO monad. Actually, all IO is kinda pure, just (IO smth) values fly behind the
by lelf 14y ago
You can think about your second version as without side-effects too. It's just in IO monad. Actually, all IO is kinda pure, just (IO smth) values fly behind the scenes. All dirty unpure things happen in runtime.
And in the first snippet it is in STM monad, and you can do, for example
modifyTVar :: TVar a -> (a -> a) -> STM ()
You should understand monads more to grok it, it's quite beautiful.