-- Synchronous stream processors module SPS where newtype S i o = S (i->(o,S i o)) feed (S sps) i = sps i runS _ [] = [] runS sps (i:is) = continue (feed sps i) is continue c is = fst c:runS (snd c) is mapS f = S sps where sps i = (f i,S sps) mapAccumS f s0 = S (sps s0) where sps s1 i = case f s1 i of (s2,o) -> (o,S (sps s2)) --(>*<) :: S i1 o1 -> S i2 o2 -> S (i1,i2) (o1,o2) sps1 >*< sps2 = S sps where sps (i1,i2) = ((fst o1,fst o2),snd o1>*+<) :: S i1 o1 -> S i2 o2 -> S (Either i1 i2) (Either o1 o2) sps1 >+< sps2 = S sps where sps (Left i1) = (Left o1,sps1'>++****<(sps1b-<-sps2b)} --} assert Separation3 = All sps1 . All sps2 . All is . {split (runS (sps1>+