3 ms·
How would you handle state other than passing it around? The fundamental thing that Haskell and Elm do is that they don't have mutable values. They create a ne
by elbear 6y ago
How would you handle state other than passing it around?
The fundamental thing that Haskell and Elm do is that they don't have mutable values. They create a new value from the old one. You never mutate a record the way you mutate a JS object or a Python dict.
- ImprobableTruth 6y ago> How would you handle state other than passing it around? By only passing and updating the relevant bits of state. >The fundamental thing that Haskell and Elm do is that they don't have mutable values. They create a new value from the old one. If we're talking about the context of a game, you'll be very likely using monads where this isn't the case (IO, ST). Not to mention, even if you do just use a normal state monad, if you don't keep the old value around, there's no functional difference between mutating the entire program state and creating a new program state while forgetting the old.