| #{name}
- $case verChange
- $of This oldVersion
- | #{oldVersion}
+ $case change
+ $of This (Version old)
+ | #{old}
|
- $of That newVersion
+ $of That (Version new)
|
- | #{newVersion}
- $of These oldVersion newVersion
- | #{oldVersion}
- | #{newVersion}
+ | #{new}
+ $of These (Version old) (Version new)
+ | #{old}
+ | #{new}
|]
diff --git a/Handler/StackageHome.hs b/Handler/StackageHome.hs
index 7ee954d..c28130d 100644
--- a/Handler/StackageHome.hs
+++ b/Handler/StackageHome.hs
@@ -7,7 +7,6 @@ module Handler.StackageHome
) where
import Import
-import qualified Data.HashMap.Strict as HashMap
import Data.These
import Data.Time (FormatTime)
import Stackage.Database
diff --git a/Stackage/Snapshot/Diff.hs b/Stackage/Snapshot/Diff.hs
index f041df4..eec4db2 100644
--- a/Stackage/Snapshot/Diff.hs
+++ b/Stackage/Snapshot/Diff.hs
@@ -2,7 +2,8 @@
module Stackage.Snapshot.Diff
( getSnapshotDiff
, snapshotDiff
- , SnapshotDiff
+ , SnapshotDiff()
+ , toDiffList
, VersionChange(..)
) where
@@ -13,10 +14,13 @@ import ClassyPrelude
import Data.These
import Stackage.Database (SnapshotId, PackageListingInfo(..),
GetStackageDatabase, getPackages)
-type PackageName = Text
-type Version = Text
+import Types
-type SnapshotDiff = HashMap PackageName VersionChange
+newtype SnapshotDiff
+ = SnapshotDiff { unSnapshotDiff :: HashMap PackageName VersionChange }
+
+toDiffList :: SnapshotDiff -> [(PackageName, VersionChange)]
+toDiffList = sortOn (toCaseFold . unPackageName . fst) . HashMap.toList . unSnapshotDiff
-- | Versions of a package as it occurs in the listings provided to `snapshotDiff`.
--
@@ -32,6 +36,8 @@ getSnapshotDiff :: GetStackageDatabase m => SnapshotId -> SnapshotId -> m Snapsh
getSnapshotDiff a b = snapshotDiff <$> getPackages a <*> getPackages b
snapshotDiff :: [PackageListingInfo] -> [PackageListingInfo] -> SnapshotDiff
-snapshotDiff as bs = HashMap.filter changed $ alignWith VersionChange (toMap as) (toMap bs)
+snapshotDiff as bs =
+ SnapshotDiff $ HashMap.filter changed
+ $ alignWith VersionChange (toMap as) (toMap bs)
where
- toMap = HashMap.fromList . map (pliName &&& pliVersion)
+ toMap = HashMap.fromList . map (PackageName . pliName &&& Version . pliVersion)
diff --git a/templates/stackage-diff.hamlet b/templates/stackage-diff.hamlet
index 8197d95..d2b90b6 100644
--- a/templates/stackage-diff.hamlet
+++ b/templates/stackage-diff.hamlet
@@ -33,15 +33,15 @@
$else
|