
On Tue, Jan 28, 2014 at 3:03 AM, Corentin Dupont
Hi Haskell-Caféists! I have a small DSL for a game. Some instructions have effects (change the game state), some not. -> In short, my question is: how can I semantically separate instructions with effect from the others? i.e. how can I mark down and track those effects?
Hi, Corentin, This is very much like what we did in our work on adding fine-grained effect specification to the Par monad in the LVish library (http://hackage.haskell.org/package/lvish). Just as Jacques suggested up-thread, we did it by adding an extra phantom type parameter to the monad which we call the "determinism level". At its simplest, there are only two of these levels, Det and QuasiDet, for deterministic and quasi-deterministic: data Determinism = Det | QuasiDet and the first parameter passed to the Par type constructor is of kind Determinism (we have to turn on the DataKinds extension for this). Doing so allows the static type of a Par computation to reflect its determinism or quasi-determinism guarantee. (The effects you can perform in deterministic computations are a subset of the ones you can do in quasi-deterministic computations.) The beginning of section 6 of our POPL paper on LVish (http://www.cs.indiana.edu/~lkuper/papers/lvish-popl14.pdf) discusses this feature. In more recent work, we've extended this to allow a more fine-grained menu of effects to choose from, to the point where we've begun calling it an "effect level" rather than merely "determinism level". Good luck with it! Lately I have gotten a lot of mileage out of thinking of monads as embedded DSLs. Projects like yours really put that analogy to use. :) Lindsey