Reputation: 1413
There is an implementation of HashMap
, in Haskell
, but I can't find parallel version of it. It's necessary to solve problem below.
Say, I have two hashmaps HashMap a b
, I want to union it with condition, Now I use unionWith
function, but the problem is that equivalence of my a
keys is very long procedure (it's a graphs). So I'd like to perform it in parallel. How can I do it?
Upvotes: 5
Views: 276
Reputation: 6778
You could create a newtype
around HashMap
, then define a new Eq
instance that is as parallel as you like using Control.Parallel
. Unfortunately you'll have to write all that code yourself, I don't think there is any out of the box parallel implementations.
import Control.Parallel
newtype ParHashMap k v = ParHashMap { unPar :: HashMap k v }
instance (Eq k, Eq v) => Eq (ParHashMap k v) where
ParHashMap hm1 == ParHashMap hm2 = ...
I'm not sure which HashMap
you're using (I recommend unordered-containers
), so I can't write the Eq
instance, but it should be fairly simple to evaluate the equality of each node in parallel.
Upvotes: 1