From f3c5eb85d5f78330fc7d4557bcceb70ea76a91e0 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Wed, 30 Oct 2019 12:30:51 -0400 Subject: [PATCH] Replace use of deprecated foldVersionRange' Co-authored-by: Herbert Valerio Riedel --- Distribution/Server/Framework/Instances.hs | 25 ++++++++++---------- Distribution/Server/Framework/MemSize.hs | 27 +++++++++++----------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/Distribution/Server/Framework/Instances.hs b/Distribution/Server/Framework/Instances.hs index 211beb5fa..217d67e9b 100644 --- a/Distribution/Server/Framework/Instances.hs +++ b/Distribution/Server/Framework/Instances.hs @@ -85,18 +85,19 @@ instance SafeCopy VersionRange where version = 2 errorTypeName _ = "VersionRange" kind = extension - putCopy = contain . foldVersionRange' - (putWord8 0) - (\v -> putWord8 1 >> safePut v) - (\v -> putWord8 2 >> safePut v) - (\v -> putWord8 3 >> safePut v) - (\v -> putWord8 4 >> safePut v) - (\v -> putWord8 5 >> safePut v) - (\v _ -> putWord8 6 >> safePut v) - (\v _ -> putWord8 10 >> safePut v) -- since Cabal-2.0 - (\r1 r2 -> putWord8 7 >> r1 >> r2) - (\r1 r2 -> putWord8 8 >> r1 >> r2) - (\r -> putWord8 9 >> r) + putCopy = contain . cataVersionRange f + where + f AnyVersionF = putWord8 0 + f (ThisVersionF v) = putWord8 1 >> safePut v + f (LaterVersionF v) = putWord8 2 >> safePut v + f (EarlierVersionF v) = putWord8 3 >> safePut v + f (OrLaterVersionF v) = putWord8 4 >> safePut v + f (OrEarlierVersionF v) = putWord8 5 >> safePut v + f (WildcardVersionF v) = putWord8 6 >> safePut v + f (MajorBoundVersionF v) = putWord8 10 >> safePut v -- since Cabal-2.0 + f (UnionVersionRangesF u v) = putWord8 7 >> u >> v + f (IntersectVersionRangesF u v) = putWord8 8 >> u >> v + f (VersionRangeParensF v) = putWord8 9 >> v getCopy = contain getVR where getVR = do diff --git a/Distribution/Server/Framework/MemSize.hs b/Distribution/Server/Framework/MemSize.hs index c05a8eb35..b1cc3371f 100644 --- a/Distribution/Server/Framework/MemSize.hs +++ b/Distribution/Server/Framework/MemSize.hs @@ -31,7 +31,7 @@ import qualified Data.Version as Ver import Distribution.Package (PackageIdentifier(..), PackageName, unPackageName) import Distribution.PackageDescription (FlagName, unFlagName) -import Distribution.Version (Version, VersionRange, foldVersionRange') +import Distribution.Version (Version, VersionRange, cataVersionRange, VersionRangeF(..)) import Distribution.System (Arch(..), OS(..)) import Distribution.Compiler (CompilerFlavor(..), CompilerId(..)) @@ -238,18 +238,19 @@ instance MemSize Version where memSize _ = 2 instance MemSize VersionRange where - memSize = - foldVersionRange' memSize0 -- any - memSize1 -- == v - memSize1 -- > v - memSize1 -- < v - (\v -> 7 + 2 * memSize v) -- >= v - (\v -> 7 + 2 * memSize v) -- <= v - (\v _v' -> memSize1 v) -- == v.* - (\v _v' -> memSize1 v) -- ^>= v.* - memSize2 -- _ || _ - memSize2 -- _ && _ - memSize1 -- (_) + memSize = cataVersionRange f + where + f AnyVersionF = memSize0 + f (ThisVersionF v) = memSize1 v + f (LaterVersionF v) = memSize1 v + f (OrLaterVersionF v) = memSize1 v + f (EarlierVersionF v) = memSize1 v + f (OrEarlierVersionF v) = memSize1 v + f (WildcardVersionF v) = memSize1 v + f (MajorBoundVersionF v) = memSize1 v + f (UnionVersionRangesF u v) = memSize2 u v + f (IntersectVersionRangesF u v) = memSize2 u v + f (VersionRangeParensF v) = memSize1 v instance MemSize PackageIdentifier where memSize (PackageIdentifier a b) = memSize2 a b