Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is Data.Monoid.Coproduct the semi-direct product? #50

Open
juliapath opened this issue Aug 30, 2021 · 1 comment
Open

Why is Data.Monoid.Coproduct the semi-direct product? #50

juliapath opened this issue Aug 30, 2021 · 1 comment

Comments

@juliapath
Copy link

juliapath commented Aug 30, 2021

The documentation for the lazy version says

m :+: n is the coproduct of monoids m and n. Values of type m :+: n consist of alternating lists of m and n values.

That much is true, in the internal presentation, but there is no way to actually access this structure. Specifically there should be a Bifoldable instance, to make good on the universal property of the coproduct:

For all monoid homomorphisms f₁ :: M₁ → M, f₂ :: M₂ → M there is a unique monoid homomorphism bifoldMap f₁ f₂ :: M₁ :+: M₂ → M, such that bifoldMap f₁ f₂ . inL = f₁ and bifoldMap f₁ f₂ . inR = f₂.

Instead the only way to get anything out of M₁ :+: M₂ is untangle, which as far as I can tell just maps the coproduct to the semidirect product M₁ ⋉ M₂. Moreover the strict version already does this reduction directly.

But there already is Data.Monoid.SemiDirectProduct, which seems to be the same thing, but with it's variables flipped, slightly different presentation, constraints and function names.

Am I missing something? Is Data.Monoid.Coproduct the coproduct in some other category than the category of monoids? Is there a difference between Data.Monoid.Coproduct and Data.Monoid.SemiDirectProduct that I missed?

@juliapath juliapath changed the title Why is the Data.Monoid.Coproduct the semi-direct product? Why is Data.Monoid.Coproduct the semi-direct product? Aug 30, 2021
@byorgey
Copy link
Member

byorgey commented Sep 2, 2021

No particular reason --- mostly because when I wrote that module 9 years ago, I didn't even know what a semi-direct product was. untangle was not added for any particularly principled reason, but just because I needed it for something in diagrams. The Data.Monoid.SemiDirectProduct module was added much later (and I didn't notice the overlap). I'm very happy to entertain any changes you might like to suggest!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants