1
- {-# LANGUAGE CPP, RecordWildCards #-}
1
+ {-# LANGUAGE CPP, RecordWildCards, DeriveAnyClass, DeriveGeneric #-}
2
2
3
3
module Types
4
4
( PackageName
@@ -17,9 +17,11 @@ module Types
17
17
18
18
import Control.Applicative
19
19
import Data.Char (isDigit )
20
- import Data.List (intercalate )
20
+ import Data.List (intercalate , sort )
21
21
import Data.Version (Version , showVersion , parseVersion )
22
22
import Development.Shake (Action )
23
+ import Development.Shake.Classes (Binary , Hashable , NFData )
24
+ import GHC.Generics
23
25
import Text.ParserCombinators.ReadP (ReadP ,
24
26
char , endBy1 , munch , readP_to_S , satisfy , skipSpaces )
25
27
@@ -32,6 +34,7 @@ type PackageName = String
32
34
-- a hyphen between the two parts. i.e.: "acme-inator-0.1.0.0". Note that no
33
35
-- component of a package name can start with a digit.
34
36
data Package = Package { pkgName :: PackageName , pkgVersion :: Version }
37
+ deriving (Eq , Ord , Generic , Hashable , Binary , NFData )
35
38
36
39
readPackageP :: ReadP Package
37
40
readPackageP = do
@@ -58,7 +61,7 @@ instance Show Package where
58
61
data IncludeType = IncGHC | IncGHCLib | IncGHCTool | IncLib | IncTool
59
62
| IncIfWindows IncludeType
60
63
| IncIfNotWindows IncludeType
61
- deriving (Eq , Read , Show )
64
+ deriving (Eq , Read , Show , Ord , Generic , Hashable , Binary , NFData )
62
65
63
66
64
67
readFixedPacakgeP :: (Version -> a ) -> String -> ReadP a
@@ -72,6 +75,7 @@ readFixedPacakgeP f fixedName = do
72
75
-- | Version of the platform itself.
73
76
-- 'Read'/'Show' format is "haskell-platform-<version>"
74
77
newtype HpVersion = HpVersion { hpVersion :: Version }
78
+ deriving (Eq , Generic , Hashable , Binary , NFData )
75
79
instance Read HpVersion where
76
80
readsPrec _ = readP_to_S $ readFixedPacakgeP HpVersion " haskell-platform"
77
81
instance Show HpVersion where
@@ -80,6 +84,7 @@ instance Show HpVersion where
80
84
-- | Version of the GHC.
81
85
-- 'Read'/'Show' format is "ghc-<version>"
82
86
newtype GhcVersion = GhcVersion { ghcVersion :: Version }
87
+ deriving (Eq , Generic , Hashable , Binary , NFData )
83
88
instance Read GhcVersion where
84
89
readsPrec _ = readP_to_S $ readFixedPacakgeP GhcVersion " ghc"
85
90
instance Show GhcVersion where
@@ -94,7 +99,14 @@ data Release = Release
94
99
, relMinimalIncludes :: [Include ]
95
100
, relIncludes :: [Include ]
96
101
}
97
- deriving (Read , Show )
102
+ deriving (Read , Show , Generic , Hashable , Binary , NFData )
103
+ -- The order of entries in the relMinimalIncludes and relIncludes does not
104
+ -- matter for equality (and these lists will have 20-40 entries max with no
105
+ -- duplicates), so this Eq instance addresses that.
106
+ instance Eq Release where
107
+ (Release v1 m1 i1) == (Release v2 m2 i2) =
108
+ (v1 == v2) && (sortedEq m1 m2) && (sortedEq i1 i2)
109
+ where sortedEq as bs = (sort as) == (sort bs)
98
110
99
111
-- | The configuration of a build. These are the parameters of the build that
100
112
-- specify what type of system this build of Haskell Platform is for. It
@@ -111,7 +123,7 @@ data BuildConfig = BuildConfig
111
123
, bcPrefix :: Maybe FilePath -- ex.: "/usr/local/haskell"
112
124
, bcIncludeExtra :: Bool
113
125
}
114
- deriving (Read , Show )
126
+ deriving (Read , Show , Eq , Generic , Hashable , Binary , NFData )
115
127
116
128
-- | A function that is used for the actions after untar-ing GHC.
117
129
-- The build configuration and file path of the untar-ed directory is
0 commit comments