Closed andrewthad closed 7 years ago
It would be interesting to see if expand
is sufficient. I can definitely get the right type; have to check semantics.
It seems that expand
is sufficient, and that even the Comonad
constraint is unnecessary. I can't claim to understand what's really going on, but following the types leads to this:
unzipGen :: forall m f a b r. (Monad m, Bifunctor f, Functor (f (a, b)))
=> Stream (f (a, b)) m r -> Stream (f a) (Stream (f b) m) r
unzipGen = expand $ \faxb fabx ->
bimap snd (const (faxb (first fst fabx))) fabx
which seems to work properly, though it looks strange. So I guess we probably don't need this function.
We should document that both unzips
and expand
generalize unzip
:
unzip = expand $ \p ((a, b) :> abs) -> b :> p (a :> abs)
unzip = unzips . maps (\((a,b) :> x) -> Compose (a :> (b :> x)))
Documentation added in #16.
Original issue by @treeowl: