Skip to content

Commit 4e53f6b

Browse files
committed
Value.Equal: lignEqM: refactor
1 parent 60d5647 commit 4e53f6b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Nix/Value/Equal.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,16 @@ alignEqM
5050
-> m Bool
5151
alignEqM eq fa fb =
5252
fmap
53-
isRight
53+
(isRight @() @())
5454
$ runExceptT $
55-
do
56-
pairs <-
57-
traverse
55+
traverse_
56+
(guard <=< lift . uncurry eq)
57+
=<< traverse
5858
(\case
5959
These a b -> pure (a, b)
60-
_ -> throwE ()
60+
_ -> throwE mempty
6161
)
6262
(Data.Semialign.align fa fb)
63-
traverse_ (\ (a, b) -> guard =<< lift (eq a b)) pairs
6463

6564
alignEq :: (Align f, Traversable f) => (a -> b -> Bool) -> f a -> f b -> Bool
6665
alignEq eq fa fb = runIdentity $ alignEqM (\x y -> Identity (eq x y)) fa fb

0 commit comments

Comments
 (0)