Mon Apr 22 08:40:54 EDT 2019

Summary: SeqLoop

The extension needs to happen as:

class Seq m r => SeqLoop m v r where
  zipfold :: ([r t] -> [r t] -> ([r t], [r t]))
          -> r [t] -> r [v t] -> r ([t], [v t])
  -- zipfold body initStates inputVectors = (outStates, outputVectors)

Or something like that.  The problem this solves is to unpack the
representations of arrays: inside the body function, there are only
scalar reprsentations.

This is going to take some shuffling to get right.  But it seems that
once expressed properly, the construction of instances is going to be


  (Seq m r,
   -- Generalize [] grouping functors to a,i,o
   Zip a, Traversable a,  -- accumulators
   Zip i, Traversable i,  -- inputs
   Zip o, Traversable o   -- outputs
  ) =>

  SeqLoop m r a i o where
  -- This implements the typicial "tagless-final" style where a
  -- combinator flips the nesting of representation (r) and collection
  -- (a,i,o) type constructors.
  zipfold ::
    (a (r t) -> i (r t) -> (a (r t), o (r t))) ->
    (r (a t) -> r (i t) -> (r (a t), r (o t)))

  -- zipfold loopBody initAccus inputVectors = (outAccus, outputVectors)

I'm pretty sure that's it.  The rest is implementation which can now
be done in a type-driven fashion.  That's for tomorrow morning as I
don't think it's going to be a small change.  Probably will need a new
data type.