3 ms·
This says more about your understanding of Haskell than anything else, really. The GP's example is not a _global_ variable, by the way. Global variables are no
by pictureotf 17y ago
This says more about your understanding of Haskell than anything else, really.
The GP's example is not a _global_ variable, by the way.
Global variables are not really available in Haskell, except if you use unsafePerformIO:
import System.IO.Unsafe
{-# NOINLINE global #-}
global :: IORef Int
global = unsafePerformIO $ newIORef 0
- ajross 17y agoIgnorant as charged, I guess. And the fact that neither of you can see the embarassing complexity of these solutions relative to, again, setting a variable reflects what, your corresponding ignorance of von neumann architectures?
- jrockway 17y agoOh, we see the "complexity" in implementing this. (Note: not very complex in real life.) But we also see the embarrassing complexity of maintaining software that uses a "quick global variable" here and there. It's nice to know what your software does without having to guess and pray. That is worth saying "runState foo 42" instead of just "foo".
- ajross 17y agoRight. So you guys are purists who refuse to use imperative constructs even when they're objectively simpler, either because (1) you see hidden costs the rest of us don't or (2) you're wrong. Isn't that the point of this whole argument?