[<<][meta][>>][..]
Tue Dec 6 18:19:37 EST 2011

Sys.hs

I tried to port Sys.hs to using Cons instead of (,) but this turns out
not to be possible because the Arrow instance relies on the (,) binary
tuples.

This seems like a hard constraint that's probably best to completely
avoid by not using Cons in the code, and replacing it by (,).

For the same reason we als needs instances for Nil or ().  Just added.

Another thing is that we probably don't want to use Atom/(,)/()
structures inside Sym anyway.  Sym is for composing functional
descriptions, which is a different world than the struct argument
passing that's done in Loop.

Otoh, a Sym could contain Loop code.. how to work with that?  There
seem to be some things not so clear as to how these things should
compose.  In any case, there should be enough support for it now, as
long as functions operate on Atom-wrapped atomic types.

I don't know what to do with the Sys phantom type though.  Currently
it's empty (it still had the old CompileVar stuff) so maybe move
towards that?


Anyways.. This seems to work, but is awkward:

compileLoop update init =
  _letrec 
  (\loop -> _lambda (\s -> do
                        i <- undefined -- FIXME: read input
                        (s', o) <- update (s, i)
                        -- FIXME: write output
                        -- FIXME: terminate condition
                        _app loop s))
  
  (\loop -> _app loop init)

Awkward because we can't get around the fact that composite state,
even if it's built with (,) needs to be terminated in Atom nodes.

So now, how to type the phantom type?

data Sys p m i o = 
  forall s. () -- FIXME: Add interface to phantom type
            => Sys ((s, i) -> m (s, o)) s

Something seems deeply burried.  I don't know what to express, and the
error message for compiling this doesn't help:

compileSys (Sys update init) = compileLoop update init

/home/tom/meta/dspm/0test_TML_Sys.hs:48:32:
    Ambiguous type variable `as0' in the constraint:
      (Struct s1 r as0 s2) arising from a use of `compileLoop'
    Probable fix: add a type signature that fixes these type variable(s)
    In the expression: compileLoop update init
    In an equation for `compileSys':
        compileSys (Sys update init) = compileLoop update init
Failed, modules loaded: TML, StateCont, Term, Code, Loop, Struct, Effect, Sys.




[Reply][About]
[<<][meta][>>][..]