fix diff/ ordering of cased packages with consistent use of toCaseFold

fixes #315

Thank you to @alaendle and @andreasabel
This commit is contained in:
Jens Petersen 2023-06-25 15:55:36 +08:00
parent 19de58f2ab
commit b3e7fcbfe1

View File

@ -75,14 +75,14 @@ snapshotDiff
-> [(PackageNameP, VersionP)]
-> SnapshotDiff
snapshotDiff as0 bs0 =
SnapshotDiff $ map (second VersionChange) $ go (sortEm as0) (sortEm bs0)
SnapshotDiff $ map (second VersionChange) $ go (sortOn cmp as0) (sortOn cmp bs0)
where
sortEm = sortOn (toCaseFold . textDisplay . fst)
cmp = toCaseFold . textDisplay . fst
go as [] = map (second This) as
go [] bs = map (second That) bs
go (a:as) (b:bs) =
case compare (fst a) (fst b) of
case (compare `on` cmp) a b of
EQ
| snd a == snd b -> go as bs
| otherwise -> (fst a, These (snd a) (snd b)) : go as bs