
On Fri, Jun 17, 2022 at 05:01:55PM +0200, Olaf Klinke wrote:
Is there prior art to the following generalisation?
traverseArrow :: Traversable t => a x y -> a (t x) (t y)
Perhaps you are looking for this:
https://github.com/tomjaguarpaw/Arrows2/issues/3#issuecomment-561973678
Thanks Tom, can you explain what's behind this implementation, for those unfamiliar with arrow syntax? I guess [*] that the Traversal type used is a manifestation of the fact that one can transform any traversable structure (t a) into ([a],t ()) and sort the contents of the linked list back into their original places? This way, arbitrary traversals can be reduced to traversals over linked lists. Then the ArrowChoice is needed to pattern match on the list constructors? E. Kmett's profunctor implementation wanderA, linked to from the end of the discussion, seems to be missing from the current Data.Profunctor.Traversing module. Olaf [*] Structurally, Traversal a r b ~ Free (Const a :*: ((->) r)) b and also their Applicative instances seem to match on first glance. In particular, Traversal a () b ~ ([a],b) whence traversal :: Traversable t => t a -> Traversal a b (t b) can be specialized to traversal :: Traversable t => t a -> ([a],t ())