<div dir="ltr"><div>I do have many newtypes for different datas, and defined correct Monoid instances for them. The problem arises when you need to convert between them in different ways, or when you write generic HashMap-related code.<br></div><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 20, 2015 at 3:44 PM, Tobias Dammers <span dir="ltr"><<a href="mailto:tdammers@gmail.com" target="_blank">tdammers@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Pragmatic workaround: newtype-wrap HashMap?<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Jan 20, 2015 at 02:33:22PM +0200, Konstantine Rybnikov wrote:<br>
> Hi!<br>
><br>
> I'm working with a lot of HashMap's and it's very frustrating how many<br>
> times I've "lost" my data because of usage of either a Monoid instance of a<br>
> HashMap (which is defined as H.union, which, upon collision, takes value<br>
> from first hm and discards from second), or just using fromList in the<br>
> wrong place. Whereas the data I'm working is is mostly defined as (Monoid v<br>
> => HashMap k v), so what I need "by default" is actually something like<br>
> `H.unionWith (<>)`.<br>
><br>
> What I was wondering is this: is something like MonoidHashMap is desired to<br>
> be in unordered-containers, or is this use-case only popular in my<br>
> programs? I'm asking because I have a feeling that this thing might be<br>
> useful quite a lot for others also. If not -- sorry for bothering :)<br>
><br>
> Cheers!<br>
<br>
</div></div><span class="im HOEnZb">> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br>
<br>
</span><span class="HOEnZb"><font color="#888888">--<br>
Tobias Dammers - <a href="mailto:tobias@twokings.nl">tobias@twokings.nl</a> - 070-3457628 - <a href="http://www.twokings.nl" target="_blank">www.twokings.nl</a><br>
Maandag t/m donderdag van 9.00 tot 17.30<br>
Voor dringende vragen, mail naar <a href="mailto:support@twokings.nl">support@twokings.nl</a><br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div></div></div></div></div>