The >.<
combinator
The combinator
(>.<) :: F a b -> F c d -> F (a, c) (b, d)
sends components to the corresponding subfudgets, and output a pair
whenever one subfudget outputs a message, if the other subfudget has
output a message at all. Its definition is
infixl 5 >.<
a >.< b = combine2SP >^^=< (a >+< b) >=^^< splitSP
combine2SP :: SP (Either a b) (a,b)
combine2SP = comb Nothing Nothing where
comb ma mb =
(case (ma,mb) of
(Just a,Just b) -> putSP (a,b)
_ -> id) $
getSP $ \y -> case y of
Left a -> comb (Just a) mb
Right b -> comb ma (Just b)