Sat Dec 31 12:00:33 EST 2011

Inference check

Looks like the roller coaster ride of yesterday and a night sleep
payed off.  Next is to check if the inference for _get' works properly
now in a real function body.

It doesn't:

      No instance for (Struct Term Code as0 (Code (L (Tint -> Tfloat))))
        arising from a use of `compile3'
      Possible fix:
        add an instance declaration for
        (Struct Term Code as0 (Code (L (Tint -> Tfloat))))
      In the second argument of `_def', namely `(compile3 f2)'
      In the second argument of `($)', namely `_def "fun" (compile3 f2)'
      In the second argument of `($)', namely
        `term $ _def "fun" (compile3 f2)'
  Failed, modules loaded: Type, Array, TML, Sys, Term, Code, Loop, Struct, PrettyC, SArray, StateCont.

Is this really just a missing instance of a symptom of something else.
It seems that in t20 structs of pointers work just fine, so something
else is going on here.

2 questions:
  - why doesn't as0 resolve to (L (Tint -> Tfloat))

  - is Struct Term Code (L (Tint -> Tfloat)) (Code (L (Tint -> Tfloat))) defined?

The latter should be the case because of 

  TMLword t => TMLword (Tint -> t)
  TMLword t => TMLword (L t)

So the question is, why isn't as0 fixed?

Maybe now it's time to move to the approach where we just transform a
struct of arrays into an array of structs.  This means that the
"distribution" needs to be solved at a different level, or somehow

Maybe it's just literal.. What about adding the Struct constraint here:

  instance (TMLword t,
            Array m r a t,
            StructRepr r,
            Struct stx r (L (a t)) (r (L (a t))) -- HERE
            Loop stx m r) 
           => SArray stx m r (L (a t)) (L t) where 

No that didn't solve anything.  I'm back (never away?) from not
understanding the dependency structure and why it doesn't want to just
infer dammit!

  l16 = compile3 f2

    :: Struct Term Code as (Code (L (Tint -> Tfloat))) =>
            ((L (Tint -> (L Tfloat, L Tfloat)), ((as, as), L Tint))
             -> StateCont.SC Code.CompState Term Tint))

How come that as isn't fixed?