Closed masaeedu closed 4 years ago
Hmmm. I suppose this is just a general Fact About Hask! I'd love a PR which does the same for Wedge
and Can
as well. I think i repeat myself a bit (co)distributing over both of those as well.
Sorry, wrong button 😅
It is indeed a general fact about Hask. Every endofunctor on Hask is oplax monoidal between the (,)
structure and itself, and also lax monoidal between the Either
structure and itself.
I can take a crack at a PR. Do you want a general purpose unzip
and undecide
or one for each data type?
i think it would be useful to write an Internal.hs
module where we abstract away some of this work, and yes, i'd love an unzip
and undecide
for each module! Thank you 😄
Only tangetially related, but I think the fact in question actually holds for arbitrary categories with products and coproducts, i.e. every endofunctor in a cartesian category oplaxly preserves the product, and every endofunctor in a cocartesian category laxly preserves the coproduct.
So with these things:
undistributeSmash :: Wedge (Smash a c) (Smash b c) -> Smash (Wedge a b) c
pairSmashCan :: Smash (Can a b) c -> Can (Smash a c) (Smash b c)
the code is doing the same thing, but for a non-Bifunctor
bifunctor, a non-Either
coproduct, and a non-(,)
product.
Yes, they are intended to be very general facts about how additive and multiplicative conjunctions and disjunctions play with each other. The second fact was taken from the coherence maps between the conjunctions in a linear logical view of symm. mon. cats.
I was reading through some of the code and spotted this thing:
I think we can reuse some of the other work in the module by writing:
or more generally by just writing: