Wed Dec 7 01:34:52 EST 2011
Now moving on to trying to make this compilation step work, I'm stuck
at fixing the types. This is where I got, which doesn't work. I
suppose the culprit is Struct stx r su which sort of "opens up" the
state.. Maybe existentials should be next on the list.
Or.. I can give up on the Arrow abstraction and just use an
alternative that doesn't need the data hiding.
I don't know.. It seems a bit irrelevant. The goals is to be able to
use the standard arrow interfaces so the arrow notation can be used,
but is this really so important?
forall s i o stx m r su.
(StructComp stx s,
StructComp stx i,
StructComp stx o,
Struct stx r su s,
Loop stx m r) =>
-- ((s, i) -> m (s, o)) -> s
Sys stx m i o
-> m (r Tint)
compileLoop (Sys update init) =
_letrec open body where
open loop =
(_lambda (\s -> do
(s' :: s, o :: o) <- (update (s :: s, undefined :: i)) :: m (s, o)
-- FIXME: write output
-- FIXME: terminate condition
_app loop s')) :: m (r (su -> m Tint))
body loop =
_app loop (init :: s)
Anyway, because stx already appears as a Sys parameter, it might be
good to just dump the whole compiler in there, one that generates an
init and update function.
Ok, for now I've exposed sysSer, sysPar and sysPure as non-hiding
primitive operations that represent systems as (update,init) pairs.
TODO: It would be a good exercise to punch through the ignorance and
really understand why this doesn't work instead of avoiding
confrontation once again.