haskellari / lattices

Fine-grained lattice primitives for Haskell
BSD 3-Clause "New" or "Revised" License
35 stars 15 forks source link

HashMap JoinSemiLattice/MeetSemiLattice instances look wrong #50

Closed lambdageek closed 7 years ago

lambdageek commented 7 years ago

Maybe I'm missing something, but shouldn't the join/meet semilattice instances for HashMap k v be analogous to Map k v? That is:

instance (Eq k, Hashable k, JoinSemiLattice v) => JoinSemiLattice (HM.HashMap k v) where
  (\/) = HM.unionWith (\/)

(and similarly for Meet)

lambdageek commented 7 years ago

If nothing else the present instance for JoinSemiLattice is wrong since HM.union is not commutative.

phadej commented 7 years ago

They most likely are, and I'm :+1: for making them the similar to Map instances. Also HashSet to be similar to Set. And we need to add tests for all of them. At least as with Map.