Thu Oct 20 10:34:36 EDT 2011
Fold is good
So how to express nesting of fold?
I need an example for this to be meaningful at all. Maybe it's time
to wait wait a bit to try to do this in a generic style, and write the
two cases explicitly first.
Value => Sys folds (trivially) over streams.
Code => Sys == TermFun folds over C input prototypes
Here "==" is a morphism, not a strict identity: a Code => Sys can be
translated to a TermFun.
Note that I really don't care about TermFun : it is an intermediate
representation. The starting point is Sys and TML.
So fold should only reference those two, right?
First, let's find a name for this recursion pattern
mapfold :: (s -> i -> (s, o)) -> s -> [i] -> [o]
mapfold f s (i:is) = (o:os) where
(s', o) = f s i
os = mapfold f s' is
Maybe I'm looking at the wrong type. Looking at PD, what I want to do
is more something like this:
((s,i) -> (s,o)) -> ((s, A i) -> (s, A o))
I'm getting confused again.. Too abstract... Need examples.