Open MarisaKirisame opened 5 years ago
Same question here. Not sure whether it's doable though since STRef
and IORef
doesn't have Ord
instance. For now my workaround relies on Ord
instance of the descriptor:
cluster :: Ord a => [(UF.Point s a, b)] -> ST s (M.Map a [b])
cluster pairs =
(M.map ($ []) . M.fromListWith (flip (.)))
<$> mapM
( \(uf, c) -> do
cRep <- UF.descriptor =<< UF.repr uf
pure (cRep, (c :))
)
pairs
in which pairs
is the list of Point
s, zipped with data you want to attach to those points respectively.
I need to use point as key for a map.