Skip to content

Commit 09865f6

Browse files
committed
Revert "Handle undefined MIN_VERSION_base in Distribution.Utils.BinaryWithFingerprint"
This reverts commit eca045b. Revert "Add fingerprint of Generic representation when serializing." This reverts commit ebcae71.
1 parent 369a8c2 commit 09865f6

File tree

7 files changed

+19
-128
lines changed

7 files changed

+19
-128
lines changed

Cabal/Cabal.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ library
239239
Distribution.Utils.NubList
240240
Distribution.Utils.ShortText
241241
Distribution.Utils.Progress
242-
Distribution.Utils.BinaryWithFingerprint
243242
Distribution.Verbosity
244243
Distribution.Version
245244
Language.Haskell.Extension

Cabal/Distribution/Simple/Configure.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ import qualified Distribution.Simple.HaskellSuite as HaskellSuite
110110

111111
import Control.Exception
112112
( ErrorCall, Exception, evaluate, throw, throwIO, try )
113-
import Distribution.Utils.BinaryWithFingerprint
113+
import Distribution.Compat.Binary ( decodeOrFailIO, encode )
114114
import Data.ByteString.Lazy (ByteString)
115115
import qualified Data.ByteString as BS
116116
import qualified Data.ByteString.Lazy.Char8 as BLC8
@@ -199,7 +199,7 @@ getConfigStateFile filename = do
199199
Right x -> x
200200

201201
let getStoredValue = do
202-
result <- decodeWithFingerprintOrFailIO (BLC8.tail body)
202+
result <- decodeOrFailIO (BLC8.tail body)
203203
case result of
204204
Left _ -> throw ConfigStateFileNoParse
205205
Right x -> return x
@@ -244,7 +244,7 @@ writePersistBuildConfig :: FilePath -- ^ The @dist@ directory path.
244244
writePersistBuildConfig distPref lbi = do
245245
createDirectoryIfMissing False distPref
246246
writeFileAtomic (localBuildInfoFile distPref) $
247-
BLC8.unlines [showHeader pkgId, encodeWithFingerprint lbi]
247+
BLC8.unlines [showHeader pkgId, encode lbi]
248248
where
249249
pkgId = localPackage lbi
250250

Cabal/Distribution/Utils/BinaryWithFingerprint.hs

Lines changed: 0 additions & 93 deletions
This file was deleted.

cabal-install/Distribution/Client/FileMonitor.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import qualified Data.Map.Strict as Map
4545
import qualified Data.Map as Map
4646
#endif
4747
import qualified Data.ByteString.Lazy as BS
48-
import qualified Distribution.Utils.BinaryWithFingerprint as Binary
48+
import qualified Distribution.Compat.Binary as Binary
4949
import qualified Data.Hashable as Hashable
5050

5151
import Control.Monad
@@ -403,7 +403,7 @@ data MonitorChangedReason a =
403403
-- See 'FileMonitor' for a full explanation.
404404
--
405405
checkFileMonitorChanged
406-
:: (Binary a, Binary b, Typeable a, Typeable b)
406+
:: (Binary a, Binary b)
407407
=> FileMonitor a b -- ^ cache file path
408408
-> FilePath -- ^ root directory
409409
-> a -- ^ guard or key value
@@ -481,23 +481,23 @@ checkFileMonitorChanged
481481
--
482482
-- This determines the type and format of the binary cache file.
483483
--
484-
readCacheFile :: (Binary a, Binary b, Typeable a, Typeable b)
484+
readCacheFile :: (Binary a, Binary b)
485485
=> FileMonitor a b
486486
-> IO (Either String (MonitorStateFileSet, a, b))
487487
readCacheFile FileMonitor {fileMonitorCacheFile} =
488488
withBinaryFile fileMonitorCacheFile ReadMode $ \hnd ->
489-
Binary.decodeWithFingerprintOrFailIO =<< BS.hGetContents hnd
489+
Binary.decodeOrFailIO =<< BS.hGetContents hnd
490490

491491
-- | Helper for writing the cache file.
492492
--
493493
-- This determines the type and format of the binary cache file.
494494
--
495-
rewriteCacheFile :: (Binary a, Binary b, Typeable a, Typeable b)
495+
rewriteCacheFile :: (Binary a, Binary b)
496496
=> FileMonitor a b
497497
-> MonitorStateFileSet -> a -> b -> IO ()
498498
rewriteCacheFile FileMonitor {fileMonitorCacheFile} fileset key result =
499499
writeFileAtomic fileMonitorCacheFile $
500-
Binary.encodeWithFingerprint (fileset, key, result)
500+
Binary.encode (fileset, key, result)
501501

502502
-- | Probe the file system to see if any of the monitored files have changed.
503503
--
@@ -758,7 +758,7 @@ probeMonitorStateGlobRel _ _ _ _ MonitorStateGlobDirTrailing =
758758
-- any files then you can use @Nothing@ for the timestamp parameter.
759759
--
760760
updateFileMonitor
761-
:: (Binary a, Binary b, Typeable a, Typeable b)
761+
:: (Binary a, Binary b)
762762
=> FileMonitor a b -- ^ cache file path
763763
-> FilePath -- ^ root directory
764764
-> Maybe MonitorTimestamp -- ^ timestamp when the update action started
@@ -965,7 +965,7 @@ getFileHash hashcache relfile absfile mtime =
965965
-- that the set of files to monitor can change then it's simpler just to throw
966966
-- away the structure and use a finite map.
967967
--
968-
readCacheFileHashes :: (Binary a, Binary b, Typeable a, Typeable b)
968+
readCacheFileHashes :: (Binary a, Binary b)
969969
=> FileMonitor a b -> IO FileHashCache
970970
readCacheFileHashes monitor =
971971
handleDoesNotExist Map.empty $

cabal-install/Distribution/Client/ProjectPlanOutput.hs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{-# LANGUAGE BangPatterns, RecordWildCards, NamedFieldPuns,
22
DeriveGeneric, DeriveDataTypeable, GeneralizedNewtypeDeriving,
33
ScopedTypeVariables #-}
4-
{-# LANGUAGE TypeFamilies #-}
5-
{-# LANGUAGE UndecidableInstances #-}
64

75
module Distribution.Client.ProjectPlanOutput (
86
-- * Plan output
@@ -43,7 +41,6 @@ import Distribution.Text
4341
import qualified Distribution.Compat.Graph as Graph
4442
import Distribution.Compat.Graph (Graph, Node)
4543
import qualified Distribution.Compat.Binary as Binary
46-
import qualified Distribution.Utils.BinaryWithFingerprint as Binary
4744
import Distribution.Simple.Utils
4845
import Distribution.Verbosity
4946
import qualified Paths_cabal_install as Our (version)
@@ -56,7 +53,6 @@ import qualified Data.Set as Set
5653
import qualified Data.ByteString.Lazy as BS
5754
import qualified Data.ByteString.Builder as BB
5855

59-
import GHC.Generics
6056
import System.FilePath
6157
import System.IO
6258

@@ -328,15 +324,6 @@ encodePlanAsJson distDirLayout elaboratedInstallPlan elaboratedSharedConfig =
328324
type PackageIdSet = Set UnitId
329325
type PackagesUpToDate = PackageIdSet
330326

331-
newtype PackagesUpToDateG = PackagesUpToDateG { unPackagesUpToDateG :: PackagesUpToDate }
332-
333-
instance Binary.Binary PackagesUpToDateG
334-
335-
instance Generic PackagesUpToDateG where
336-
type Rep PackagesUpToDateG = Rep [UnitId]
337-
from = from . Set.toList . unPackagesUpToDateG
338-
to = PackagesUpToDateG . Set.fromList . to
339-
340327
data PostBuildProjectStatus = PostBuildProjectStatus {
341328

342329
-- | Packages that are known to be up to date. These were found to be
@@ -655,8 +642,7 @@ readPackagesUpToDateCacheFile DistDirLayout{distProjectCacheFile} =
655642
handleDoesNotExist Set.empty $
656643
handleDecodeFailure $
657644
withBinaryFile (distProjectCacheFile "up-to-date") ReadMode $ \hnd ->
658-
fmap (fmap unPackagesUpToDateG) .
659-
Binary.decodeWithFingerprintOrFailIO =<< BS.hGetContents hnd
645+
Binary.decodeOrFailIO =<< BS.hGetContents hnd
660646
where
661647
handleDecodeFailure = fmap (either (const Set.empty) id)
662648

@@ -667,7 +653,7 @@ readPackagesUpToDateCacheFile DistDirLayout{distProjectCacheFile} =
667653
writePackagesUpToDateCacheFile :: DistDirLayout -> PackagesUpToDate -> IO ()
668654
writePackagesUpToDateCacheFile DistDirLayout{distProjectCacheFile} upToDate =
669655
writeFileAtomic (distProjectCacheFile "up-to-date") $
670-
Binary.encodeWithFingerprint (PackagesUpToDateG upToDate)
656+
Binary.encode upToDate
671657

672658
-- Writing .ghc.environment files
673659
--

cabal-install/Distribution/Client/RebuildMonad.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ askRoot = Rebuild Reader.ask
112112
--
113113
-- Do not share 'FileMonitor's between different uses of 'rerunIfChanged'.
114114
--
115-
rerunIfChanged :: (Binary a, Binary b, Typeable a, Typeable b)
115+
rerunIfChanged :: (Binary a, Binary b)
116116
=> Verbosity
117117
-> FileMonitor a b
118118
-> a

cabal-install/tests/UnitTests/Distribution/Client/FileMonitor.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module UnitTests.Distribution.Client.FileMonitor (tests) where
22

3-
import Data.Typeable
43
import Control.Monad
54
import Control.Exception
65
import Control.Concurrent (threadDelay)
@@ -812,7 +811,7 @@ monitorFileGlobStr globstr
812811
| otherwise = error $ "Failed to parse " ++ globstr
813812

814813

815-
expectMonitorChanged :: (Binary a, Binary b, Typeable a, Typeable b)
814+
expectMonitorChanged :: (Binary a, Binary b)
816815
=> RootPath -> FileMonitor a b -> a
817816
-> IO (MonitorChangedReason a)
818817
expectMonitorChanged root monitor key = do
@@ -821,7 +820,7 @@ expectMonitorChanged root monitor key = do
821820
MonitorChanged reason -> return reason
822821
MonitorUnchanged _ _ -> throwIO $ HUnitFailure "expected change"
823822

824-
expectMonitorUnchanged :: (Binary a, Binary b, Typeable a, Typeable b)
823+
expectMonitorUnchanged :: (Binary a, Binary b)
825824
=> RootPath -> FileMonitor a b -> a
826825
-> IO (b, [MonitorFilePath])
827826
expectMonitorUnchanged root monitor key = do
@@ -830,19 +829,19 @@ expectMonitorUnchanged root monitor key = do
830829
MonitorChanged _reason -> throwIO $ HUnitFailure "expected no change"
831830
MonitorUnchanged b files -> return (b, files)
832831

833-
checkChanged :: (Binary a, Binary b, Typeable a, Typeable b)
832+
checkChanged :: (Binary a, Binary b)
834833
=> RootPath -> FileMonitor a b
835834
-> a -> IO (MonitorChanged a b)
836835
checkChanged (RootPath root) monitor key =
837836
checkFileMonitorChanged monitor root key
838837

839-
updateMonitor :: (Binary a, Binary b, Typeable a, Typeable b)
838+
updateMonitor :: (Binary a, Binary b)
840839
=> RootPath -> FileMonitor a b
841840
-> [MonitorFilePath] -> a -> b -> IO ()
842841
updateMonitor (RootPath root) monitor files key result =
843842
updateFileMonitor monitor root Nothing files key result
844843

845-
updateMonitorWithTimestamp :: (Binary a, Binary b, Typeable a, Typeable b)
844+
updateMonitorWithTimestamp :: (Binary a, Binary b)
846845
=> RootPath -> FileMonitor a b -> MonitorTimestamp
847846
-> [MonitorFilePath] -> a -> b -> IO ()
848847
updateMonitorWithTimestamp (RootPath root) monitor timestamp files key result =

0 commit comments

Comments
 (0)