<html><head></head><body><div><div><div><div>Okay, I'm fully caffeinated and out of bed.<br/></div><div><br/></div><div>Correct me if I'm wrong here, because I've never seen anyone describe maps like this, but it seems to me that for an algebraic constraint `c`, `c g ⇒ Map k g` would be a `k`-graded c-structure, and we can think of algebraic operations applied to those `g` meaningfully in that sense. For example, an indexed-list where `Group a ⇒ [(Int, a)]` can be seen as a ℤ-graded group. <br/></div><div><br/></div><div>In your example, Jack, inversion is defined on a map by `fmap inverse ≣ inverse_k0 + inverse_k1 + … + inverse k_n`, componentwise for each key. So perhaps your problem here for maps, is equivalent to finding a nice indexed-group for structure for the types: <br/></div><div><br/></div><div>```<br/></div><div>— | A functor indexed by a discrete category. Not to be confused with<br/></div><div>-- indexed as in higher functor on functor ala Atkey's Outrageous Fortune.<br/></div><div>— This is not the most general encoding.<br/></div><div>— <br/></div><div>class GradedFunctor f where<br/></div><div> imap :: (i → a → b) → f i a → f i b<br/></div><div> <br/></div><div>— Being a graded group requires that the "overall" structure be both an indexed functor,<br/></div><div>— as well as a group, so that `t i g = g_i0 + … + giN` forms a group as well.<br/></div><div>— </div><div>class (GradedFunctor t, Group (t i g), Group g) ⇒ GradedGroup t i g where<br/></div><div> ixinvert :: i→ t i g → t i g<br/></div><div>```<br/></div><div><br/></div><div>Something along those lines. <br/></div><div><br/></div><div>Thoughts? I'm spitballing here.<br/></div><div><br/></div><div>Cheers,<br/></div><div>Emily</div><div> <br/></div><div> <br/></div></div><div><div style="display: none; border: 0px; width: 0px; height: 0px; overflow: hidden; visibility: hidden;"><img src="https://r.superhuman.com/_xmUNL0Bl2vwzqt3_k03l4JHI5Bkg2x3kNhU2I_umfvmxiMh97e_gQOpXSpbdZCHxo1TOVWe_hIja36Jn1Xs4Y223a1NIG2BoVYDfhiSX9kRvnoTDzNbM33zsGIbfVvP4V99-9OU_98GZZ_ZwL1ztsbtbmjpeYpo22rWRrNGYVUPSLy6AyJ86AE0cwc.gif" alt=" " width="1" height="0" style="display: none; border: 0px; width: 0px; height: 0px; overflow: hidden; visibility: hidden;"/><!-- --></div><br/><div class="gmail_signature"></div></div><br/><div><div class="gmail_quote">On Wed, Dec 09, 2020 at 5:43 AM, <span dir="ltr"><<a href="mailto:jack@jackkelly.name" target="_blank">jack@jackkelly.name</a>></span> wrote:<br/><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote sh-color-black sh-color" style="null" id="null"><p class="sh-color-black sh-color">
December 9, 2020 4:16 AM, "Mario" <<a target="_blank" rel="noopener noreferrer" href="mailto:blamario@rogers.com">blamario@<wbr/>rogers.<wbr/>com</a>> wrote:
</p><blockquote class="sh-color-black sh-color"><p class="sh-color-black sh-color">
On 2020-12-05 7:04 p.m., Jack Kelly via Haskell-Cafe wrote:
</p><blockquote class="sh-color-black sh-color"><p class="sh-color-black sh-color">
Dunno what the answer is, but I wanted to flag it while your package is young and breaking changes
are easy. I've been meaning to have a crack at moving the reflex patch-verse over to
monoid-subclasses ( <a target="_blank" rel="noopener noreferrer" href="https://hackage.haskell.org/package/monoid-subclasses">https:/<wbr/>/<wbr/>hackage.<wbr/>haskell.<wbr/>org/<wbr/>package/<wbr/>monoid-subclasses</a> ), which I provides some
the necessary tools with different names (patch reinvents MonoidNull, and I'm hoping that a
subtraction-that-removes keys could be lawful for one of the Reductive/Cancellative classes).
</p></blockquote><p class="sh-color-black sh-color">
I'm the author and maintainer of monoid-subclasses, and I'd accept a PR that adds InverseSemigroup
without overly disturbing the existing classes. The whole purpose of the package, after all, is to
support mathematical abstractions that are richer than semigroups but are not proper groups.
</p></blockquote><p class="sh-color-black sh-color">
Thanks for the offer. There are two things I want to sort out first:
</p><p class="sh-color-black sh-color">
1. I may have erred when suggesting InverseSemigroup; "inverting" a `Group g => Map k g` via `fmap invert` might admit nonunique inverses, which gives you an even weaker structure called a Regular Semigroup.
</p><p class="sh-color-black sh-color">
2. I want to see if I can make the behaviour I want fit the existing classes provided by `monoid-subclasses` (specifically `Cancellative` and maybe `Reductive` instances for types provided by `monoidal-containers`). It might be something like `instance (MonoidNull g, Group g, Commutative g, Ord k) => Reductive (MonoidalMap k g)`, where the reduction operation subtracts values at matching keys, pruning nulls. I need to at least write out the property tests to see if it might be sound.
</p><p class="sh-color-black sh-color">
Best,
</p><p class="sh-color-black sh-color">
-- Jack</p></div></div></blockquote></div></div><br/></div></div></body></html>