3 ms·
Haskell is a general-purpose programming language, and discrete simulation-type systems like Chip's Challenge can be very elegantly modelled with nice things li
by mbrock 12y ago
Haskell is a general-purpose programming language, and discrete simulation-type systems like Chip's Challenge can be very elegantly modelled with nice things like algebraic data types, pattern matching, etc.
The code is right there on GitHub, although if you're not familiar with Haskell (and lens), it might seem cryptic. But you'll see that it is actually mostly written in an imperative style. The logic is mostly pattern matching on events to generate record updates. This is a common style in Haskell and fits the domain well.
There are other more elegantly value-oriented ways of writing simulations in Haskell; look up functional reactive programming.