Tue Jul 24 17:37:01 EDT 2018


The canonical, meaingful example is to compute the square.
But any binary function works.

suppose s is a sequence.
how to express square?

s -> (s,s) -> s^2

So what's missing is shuffling, as mentioned before.

Essentially, this is fmap (,) / snd / fst

Any kind of threading can be implemented using these operators.  It's
not pretty, but it works.

t_app_square :: Seq m r => m (r S) -> m (r S)
t_app_square = (SeqApp.uncurry SeqApp.mul) . (fmap (\x->(x,x)))

x_app_share = do
  putStrLn "--- x_app_share"
  let c@(outputs, bindings) = SeqTerm.compile m
      m = do a <- inc 1
             b <- t_app_square $ return a
             return [b]
  print outputs
  sequence $ map print bindings

--- x_app_share
[Node (SInt Nothing 0) 1]
(0,Comb2 (SInt Nothing 0) ADD (Const (SInt Nothing 1)) (Const (SInt Nothing 1)))
(1,Comb2 (SInt Nothing 0) MUL (Node (SInt Nothing 0) 0) (Node (SInt Nothing 0) 0))

My question is then, is there any notion of a pure "+" in there?
Hidden in the semantics, maybe, but it only appears operating on m (r