The these package provides an unzip for these types, but it's a "two pass" fmap-based implementation that can leak memory. I suggested a solution using traverseBia from bifunctors, but that was rejected as too hard to understand. @phadej recommended adding the unzipper to containers instead. We can do this fairly simply, and certainly more efficiently than traverseBia can (at least until ekmett/bifunctors#93 eventually reaches Hackage).
I'll try to implement these next weekend; if someone else gives it a shot, they should be mindful of the fairly subtle NOINLINE tricks that tend to be required to ensure we get the selector thunks we want.
The
thesepackage provides anunzipfor these types, but it's a "two pass"fmap-based implementation that can leak memory. I suggested a solution usingtraverseBiafrombifunctors, but that was rejected as too hard to understand. @phadej recommended adding the unzipper tocontainersinstead. We can do this fairly simply, and certainly more efficiently thantraverseBiacan (at least until ekmett/bifunctors#93 eventually reaches Hackage).I'll try to implement these next weekend; if someone else gives it a shot, they should be mindful of the fairly subtle
NOINLINEtricks that tend to be required to ensure we get the selector thunks we want.