Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
89fd3e09
Commit
89fd3e09
authored
Dec 14, 2015
by
Duncan Coutts
Browse files
Add more standard derived instances, Eq, Generic and Binary
Most types have these already. This just adds a few more.
parent
35f50ba6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Cabal/Distribution/Compiler.hs
View file @
89fd3e09
...
...
@@ -180,7 +180,7 @@ instance Binary CompilerInfo
data
AbiTag
=
NoAbiTag
|
AbiTag
String
deriving
(
Generic
,
Show
,
Read
)
deriving
(
Eq
,
Generic
,
Show
,
Read
)
instance
Binary
AbiTag
...
...
Cabal/Distribution/InstalledPackageInfo.hs
View file @
89fd3e09
...
...
@@ -112,7 +112,7 @@ data InstalledPackageInfo
haddockHTMLs
::
[
FilePath
],
pkgRoot
::
Maybe
FilePath
}
deriving
(
Generic
,
Read
,
Show
)
deriving
(
Eq
,
Generic
,
Read
,
Show
)
instance
Binary
InstalledPackageInfo
...
...
@@ -172,7 +172,7 @@ noVersion = Version [] []
-- Exposed modules
newtype
AbiHash
=
AbiHash
String
deriving
(
Show
,
Read
,
Generic
)
deriving
(
Eq
,
Show
,
Read
,
Generic
)
instance
Binary
AbiHash
instance
Text
AbiHash
where
...
...
@@ -195,7 +195,7 @@ data ExposedModule
exposedReexport
::
Maybe
OriginalModule
,
exposedSignature
::
Maybe
OriginalModule
-- This field is unused for now.
}
deriving
(
Generic
,
Read
,
Show
)
deriving
(
Eq
,
Generic
,
Read
,
Show
)
instance
Text
OriginalModule
where
disp
(
OriginalModule
ipi
m
)
=
...
...
Cabal/Distribution/PackageDescription.hs
View file @
89fd3e09
...
...
@@ -1129,12 +1129,12 @@ data GenericPackageDescription =
condTestSuites
::
[(
String
,
CondTree
ConfVar
[
Dependency
]
TestSuite
)],
condBenchmarks
::
[(
String
,
CondTree
ConfVar
[
Dependency
]
Benchmark
)]
}
deriving
(
Show
,
Eq
,
Typeable
,
Data
)
deriving
(
Show
,
Eq
,
Typeable
,
Data
,
Generic
)
instance
Package
GenericPackageDescription
where
packageId
=
packageId
.
packageDescription
--TODO: make PackageDescription an instance of Text.
instance
Binary
GenericPackageDescription
-- | A flag can represent a feature to be included, or a way of linking
-- a target against its dependencies, or in fact whatever you can think of.
...
...
@@ -1144,7 +1144,9 @@ data Flag = MkFlag
,
flagDefault
::
Bool
,
flagManual
::
Bool
}
deriving
(
Show
,
Eq
,
Typeable
,
Data
)
deriving
(
Show
,
Eq
,
Typeable
,
Data
,
Generic
)
instance
Binary
Flag
-- | A 'FlagName' is the name of a user-defined configuration flag
newtype
FlagName
=
FlagName
String
...
...
@@ -1164,7 +1166,9 @@ data ConfVar = OS OS
|
Arch
Arch
|
Flag
FlagName
|
Impl
CompilerFlavor
VersionRange
deriving
(
Eq
,
Show
,
Typeable
,
Data
)
deriving
(
Eq
,
Show
,
Typeable
,
Data
,
Generic
)
instance
Binary
ConfVar
-- | A boolean expression parameterized over the variable type used.
data
Condition
c
=
Var
c
...
...
@@ -1172,7 +1176,7 @@ data Condition c = Var c
|
CNot
(
Condition
c
)
|
COr
(
Condition
c
)
(
Condition
c
)
|
CAnd
(
Condition
c
)
(
Condition
c
)
deriving
(
Show
,
Eq
,
Typeable
,
Data
)
deriving
(
Show
,
Eq
,
Typeable
,
Data
,
Generic
)
cNot
::
Condition
a
->
Condition
a
cNot
(
Lit
b
)
=
Lit
(
not
b
)
...
...
@@ -1226,6 +1230,8 @@ instance MonadPlus Condition where
mzero
=
mempty
mplus
=
mappend
instance
Binary
c
=>
Binary
(
Condition
c
)
data
CondTree
v
c
a
=
CondNode
{
condTreeData
::
a
,
condTreeConstraints
::
c
...
...
@@ -1233,4 +1239,6 @@ data CondTree v c a = CondNode
,
CondTree
v
c
a
,
Maybe
(
CondTree
v
c
a
))]
}
deriving
(
Show
,
Eq
,
Typeable
,
Data
)
deriving
(
Show
,
Eq
,
Typeable
,
Data
,
Generic
)
instance
(
Binary
v
,
Binary
c
,
Binary
a
)
=>
Binary
(
CondTree
v
c
a
)
Cabal/Distribution/Simple/BuildTarget.hs
View file @
89fd3e09
{-# LANGUAGE DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.BuildTargets
...
...
@@ -53,6 +54,8 @@ import Data.Maybe
(
listToMaybe
,
catMaybes
)
import
Data.Either
(
partitionEithers
)
import
Distribution.Compat.Binary
(
Binary
)
import
GHC.Generics
(
Generic
)
import
qualified
Data.Map
as
Map
import
Control.Monad
import
Control.Applicative
as
AP
(
Alternative
(
..
),
Applicative
(
..
))
...
...
@@ -123,8 +126,9 @@ data BuildTarget =
-- | A specific file within a specific component.
--
|
BuildTargetFile
ComponentName
FilePath
deriving
(
Show
,
Eq
)
deriving
(
Eq
,
Show
,
Generic
)
instance
Binary
BuildTarget
-- | Read a list of user-supplied build target strings and resolve them to
-- 'BuildTarget's according to a 'PackageDescription'. If there are problems
...
...
Cabal/Distribution/Simple/Compiler.hs
View file @
89fd3e09
...
...
@@ -90,7 +90,7 @@ data Compiler = Compiler {
compilerProperties
::
M
.
Map
String
String
-- ^ A key-value map for properties not covered by the above fields.
}
deriving
(
Generic
,
Show
,
Read
)
deriving
(
Eq
,
Generic
,
Show
,
Read
)
instance
Binary
Compiler
...
...
Cabal/Distribution/Simple/InstallDirs.hs
View file @
89fd3e09
...
...
@@ -96,7 +96,7 @@ data InstallDirs dir = InstallDirs {
htmldir
::
dir
,
haddockdir
::
dir
,
sysconfdir
::
dir
}
deriving
(
Generic
,
Read
,
Show
)
}
deriving
(
Eq
,
Read
,
Show
,
Generic
)
instance
Binary
dir
=>
Binary
(
InstallDirs
dir
)
...
...
@@ -349,7 +349,8 @@ prefixRelativeInstallDirs pkgId libname compilerId platform dirs =
-- | An abstract path, possibly containing variables that need to be
-- substituted for to get a real 'FilePath'.
--
newtype
PathTemplate
=
PathTemplate
[
PathComponent
]
deriving
(
Eq
,
Generic
,
Ord
)
newtype
PathTemplate
=
PathTemplate
[
PathComponent
]
deriving
(
Eq
,
Ord
,
Generic
)
instance
Binary
PathTemplate
...
...
Cabal/Distribution/Simple/PackageIndex.hs
View file @
89fd3e09
...
...
@@ -117,7 +117,7 @@ data PackageIndex a = PackageIndex
-- preserved. See #1463 for discussion.
!
(
Map
PackageName
(
Map
Version
[
a
]))
deriving
(
Generic
,
Show
,
Read
)
deriving
(
Eq
,
Generic
,
Show
,
Read
)
instance
Binary
a
=>
Binary
(
PackageIndex
a
)
...
...
Cabal/Distribution/Simple/Program/Find.hs
View file @
89fd3e09
{-# LANGUAGE CPP, DeriveGeneric #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Simple.Program.Find
...
...
@@ -42,7 +44,8 @@ import System.FilePath
(
(
</>
),
(
<.>
),
splitSearchPath
,
searchPathSeparator
)
import
Data.List
(
intercalate
)
import
Distribution.Compat.Binary
import
GHC.Generics
-- | A search path to use when locating executables. This is analogous
-- to the unix @$PATH@ or win32 @%PATH%@ but with the ability to use
...
...
@@ -60,6 +63,9 @@ type ProgramSearchPath = [ProgramSearchPathEntry]
data
ProgramSearchPathEntry
=
ProgramSearchPathDir
FilePath
-- ^ A specific dir
|
ProgramSearchPathDefault
-- ^ The system default
deriving
(
Eq
,
Generic
)
instance
Binary
ProgramSearchPathEntry
defaultProgramSearchPath
::
ProgramSearchPath
defaultProgramSearchPath
=
[
ProgramSearchPathDefault
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment