Commit fbd9b886 by David Feuer Committed by Ben Gamari

### Implement equalKeysUFM the right way

```Originally, we compared the key lists, which was kind of silly.
Then I changed it to something fancier ... and also silly.
This is much more reasonable, should be faster, and is nice and
clear.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4500```
parent 256577fb
 ... @@ -78,12 +78,10 @@ import Outputable ... @@ -78,12 +78,10 @@ import Outputable import Data.List (foldl') import Data.List (foldl') import qualified Data.IntMap as M import qualified Data.IntMap as M import qualified Data.IntMap.Merge.Lazy as M import Control.Applicative (Const (..)) import qualified Data.Monoid as Mon import qualified Data.IntSet as S import qualified Data.IntSet as S import Data.Data import Data.Data import qualified Data.Semigroup as Semi import qualified Data.Semigroup as Semi import Data.Functor.Classes (Eq1 (..)) newtype UniqFM ele = UFM (M.IntMap ele) newtype UniqFM ele = UFM (M.IntMap ele) ... @@ -342,10 +340,7 @@ ufmToIntMap (UFM m) = m ... @@ -342,10 +340,7 @@ ufmToIntMap (UFM m) = m -- Determines whether two 'UniqFm's contain the same keys. -- Determines whether two 'UniqFm's contain the same keys. equalKeysUFM :: UniqFM a -> UniqFM b -> Bool equalKeysUFM :: UniqFM a -> UniqFM b -> Bool equalKeysUFM (UFM m1) (UFM m2) = Mon.getAll \$ getConst \$ equalKeysUFM (UFM m1) (UFM m2) = liftEq (\_ _ -> True) m1 m2 M.mergeA (M.traverseMissing (\_ _ -> Const (Mon.All False))) (M.traverseMissing (\_ _ -> Const (Mon.All False))) (M.zipWithAMatched (\_ _ _ -> Const (Mon.All True))) m1 m2 -- Instances -- Instances ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment