[<<][meta_siso][>>][..]

Tue Jul 21 22:26:10 EDT 2015

## Compilation monad

The trick is to tuck everything away in the Monad that pops up as a
parameter in Siso. Obvious in retrospect!
class Monad m => CompileSys m s where
compileInit :: s -> m s -- In: initial state, Out: test value for update
compileUpdate :: s -> m () -- In: result of applying test value to update function
That should be enough so 's' makes an appearance only for what is
needed, and then disappears into m ().
Bottom line: type 's' doesn't need to be known during the composition
phase, except for how it interacts with 'm', the compilation monad,
which basically contains the compiler (meaning of the language).
Got it:
-- The interaction s and m can be kept mininal: enough to generate a
-- test value to feed into the update equation, and a function to save
-- all state data/code into the monad.
class Monad m => CompileSys m s where
-- Generate state input expression from type.
-- The input value is ignored.
genStateIn :: s -> m s
-- Save initial state, state input expression, state output
-- expression (result of evaluating update) into the compilation
-- monad.
saveState :: (s,s,s) -> m ()

[Reply][About]

[<<][meta_siso][>>][..]