[<<][meta][>>][..]
Sat Jul 16 17:21:36 CEST 2011

Allocating nodes

Bon.  I have threading, now it's time to find out how to do the
memoization without getting into type trouble.

It seems simplest to do this in "return", because that's where we go
from the world of nested expressions to the world of CPS.  The
following doesn't work though, it's not generic enough.

   returnSC v = c where
     c s k = k s v
  
   returnSC' v = c where  
     c s k = k l (length l) where l = v:s

    Couldn't match expected type `a' against inferred type `Int'
      `a' is a rigid type variable bound by
          the type signature for `return' at <no location info>
      Expected type: Cont r s a
      Inferred type: [a] -> Int -> r

The reason for this is that the monad parameter a is fixed to Int, the
return type of length.

Look like it's to to really go to the cheat sheet.  If I recall, this
problem is mentioned in the paper[1].  Hmmm.. at first glance I can't
find it, but what happens in the code is that the let that's inserted
does seem to have the proper type for the variable.

Maybe the monad should be kept, but memoization should be made
explicit.

I wonder if [2] has better info..

[1] http://www.cs.rice.edu/~taha/publications/conference/pepm06.pdf
[2] http://www.cas.mcmaster.ca/~carette/publications/scp_metamonads.pdf



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