2 ms·
That's why Haskell programmers, for example, try to represent state in clear ways. The basic mathematical model of functions and values turns out to be able to
by mbrock 11y ago
That's why Haskell programmers, for example, try to represent state in clear ways.
The basic mathematical model of functions and values turns out to be able to represent state in several ways: the "monadic" way of composing state transforming functions; the "functional-reactive programming" way of modelling signals and events (which offers interesting solutions to the OP's game problems); various "interpreter" patterns; and so on.
I point this out just because there's a widespread misunderstanding that pure functional programming is somehow opposed to modelling state. It's definitely not. It just involves building state models on the coherent basis of functions and values.
Put simply, in Haskell, when your problem requires state, you can just use the "State" type, just like when you require I/O, you use the "IO" type.
- idanoeman 11y agoAbsolutely. In "The Awkward Squad," SPJ says "Haskell is the finest imperative programming language in the world," not entirely tongue-in-cheek. :)