Wed Jan 11 08:49:32 EST 2012
Type Level Programming
(Context: see prev entry)
What this really needs is a simple way to access the type of the
The manipulations mentioned would be so easy to do if that type would
be a simple data structure. So it looks like the thing I'm ultimately
looking for is a more systematic way to do type-level programming.
It's funny that there are already a couple of levels involved:
- Haskell type level computations (now mostly just structural induction )
- Haskell class instance code (= Term / Value construction)
- Term -> C compilation
- C -> bin compilation
- bin execution
Though from a practical pov the middle ones can be grouped = all
So, concretely. What is needed?
- Given some map specified as a type, like (A,(C,C)), construct a SSM
lifted over arrays, where each C node has an upsampler inserted.
This can be split into 2 parts.
* Construct the upsampler / pass from (A,(C,C))
* Perform simple serial composition with original update function
The trouble is that these things live in "array space" but
conceptually they need some form of "SSM space" composition. It seems
that what is missing is some kind of lift operator that bridges these
The concept that is missing is indeed a "virtual array" abstraction.
More specifically, an interface: v <- read in ; write out v
Put differently: hide n.
Or maybe: hide inputs in state? This looks a bit like partial
application: turn inputs into generators.
Something like this:
- Abstract input dereference as (si,()) -> (si,o) where si contains
all state necessary to perform the dereference.
- Compose the 2 systems using ssmSer.
Structurally, the main difference is between storing or not storing
this intermediate state. It will have to be storing, because for any
kind of interpolation we'll beed at least the previous inputs. Beyond
that state and interpolation method could be abstract.
So, the type is something like this:
Array Tfloat -> SSM
Tfloat -> Int -> SSM
Actually, the state structure is more complicated than that. There
are at least 2 components:
- Persistent state, i.e. interpolation/filter state
- One-time state constructed from the input (float values, array
pointers, array size) only live in the current iteration.
Simply put: translate "inputs" to "signals" = systems with no input.
Probably good to also do the same for output / subsampling.