Tue Feb 12 13:36:30 CET 2013

Loop inference. Automatic map?

The important parts are:
- mappings are common
- distributions are common (const over vector)
- most folds are +, (with a remote second: min/max and maybe *)

Type inference at this point does automatic lifting of all lexical
variables to streams, and then uses this typing to implement a loop.
Basically, there is no mention of a loop in the representation, only
about types.  The advantage is that inserted bindings (state) do not
need to be mentioned explitly.

The languge needs to distinguish between scalar and composite data,
with respect to a single fold.  State is *always* composite, so it
makes sense to make composite the default, and use the `const'
construct to introduce constant distribution.

- Default is parallel
- Distribution ("environment flow") is explicit: `const'
- The folding function is generic.

The main difference with standard approach is that the scalar function
that is mapped over the composite data is not visible explictly.  It
is visible only indirectly through "lifted primitives", which are in
practice always array lookups relative to the local loop context ==
index variables.