k-bx at k-bx.com
Tue Jan 20 13:52:25 UTC 2015
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.
On Tue, Jan 20, 2015 at 3:44 PM, Tobias Dammers <tdammers at gmail.com> wrote:
> Pragmatic workaround: newtype-wrap HashMap?
> On Tue, Jan 20, 2015 at 02:33:22PM +0200, Konstantine Rybnikov wrote:
> > Hi!
> > I'm working with a lot of HashMap's and it's very frustrating how many
> > times I've "lost" my data because of usage of either a Monoid instance
> of a
> > HashMap (which is defined as H.union, which, upon collision, takes value
> > from first hm and discards from second), or just using fromList in the
> > wrong place. Whereas the data I'm working is is mostly defined as
> (Monoid v
> > => HashMap k v), so what I need "by default" is actually something like
> > `H.unionWith (<>)`.
> > What I was wondering is this: is something like MonoidHashMap is desired
> > be in unordered-containers, or is this use-case only popular in my
> > programs? I'm asking because I have a feeling that this thing might be
> > useful quite a lot for others also. If not -- sorry for bothering :)
> > Cheers!
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> Tobias Dammers - tobias at twokings.nl - 070-3457628 - www.twokings.nl
> Maandag t/m donderdag van 9.00 tot 17.30
> Voor dringende vragen, mail naar support at twokings.nl
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe