I'm trying to capture a symmetrical data processing pipeline using arrows, and was wondering if bidirectional composition is possible.
Control.Arrow exposes the following
-- | Left to right composition
(>>>) :: Category cat => cat a b -> cat b c -> cat a c
-- | Right to left composition
(<<<) :: Category cat => cat b c -> cat a b -> cat a c
what I'd like, but cannot work out how to express is bidirectional composition of pairs. The type is something like.
(<^>) :: Category cat => cat (a,y) (b,z) -> cat (b,x) (c,y) -> cat (a,x) (c,z)
where the first element of each pair is to composed left-to-right, and the second to be composed right-to-left.
Product (->) (Op (->))
, exploitingData.Category
? – chiOp (->)
is flipped(->)
, i.e.Op (->) a b
is actuallyb -> a
(function going "backward"). Then the categoryProduct (->) (Op (->))
composes a morphism in(->)
(forward function) and one inOp (->)
(backward function). Hence,>>>
in this category should work as you want. – chi