Semigroup instance of UniqDFM is wrong (not associative)
This is a very minor issue in code which possibly only a GHC dev can hit.
plusUDFM is incorrect, as the behavior of replacing the values of duplicate keys is dependent on the size of
UniqDFMs being merged.
instance Semi.Semigroup (UniqDFM key a) where (<>) = plusUDFM
plusUDFM :: UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt plusUDFM udfml@(UDFM _ i) udfmr@(UDFM _ j) -- we will use the upper bound on the tag as a proxy for the set size, -- to insert the smaller one into the bigger one | i > j = insertUDFMIntoLeft udfml udfmr | otherwise = insertUDFMIntoLeft udfmr udfml
A possible solution could be to use
insertUDFMIntoLeft, but not sure if it would work correctly.
Just documenting this as I hit it myself.
Steps to reproduce
Please provide a set of concrete steps to reproduce the issue.
What do you expect the reproducer described above to do?
- GHC version used:
- Operating System:
- System Architecture: