Change license :: License to Either SPDX.License License
[cabal.git] / Cabal / Distribution / Types / AbiDependency.hs
blob9223a215c6d379a47af2f76f7212484cc255e5a7
1 {-# LANGUAGE DeriveGeneric #-}
2 module Distribution.Types.AbiDependency where
4 import Distribution.Compat.Prelude
5 import Prelude ()
7 import Distribution.Parsec.Class
8 import Distribution.Pretty
9 import Distribution.Text
11 import qualified Distribution.Compat.CharParsing as P
12 import qualified Distribution.Compat.ReadP as Parse
13 import qualified Distribution.Package as Package
14 import qualified Text.PrettyPrint as Disp
16 -- | An ABI dependency is a dependency on a library which also
17 -- records the ABI hash ('abiHash') of the library it depends
18 -- on.
20 -- The primary utility of this is to enable an extra sanity when
21 -- GHC loads libraries: it can check if the dependency has a matching
22 -- ABI and if not, refuse to load this library. This information
23 -- is critical if we are shadowing libraries; differences in the
24 -- ABI hash let us know what packages get shadowed by the new version
25 -- of a package.
26 data AbiDependency = AbiDependency {
27 depUnitId :: Package.UnitId,
28 depAbiHash :: Package.AbiHash
30 deriving (Eq, Generic, Read, Show)
32 instance Pretty AbiDependency where
33 pretty (AbiDependency uid abi) =
34 disp uid <<>> Disp.char '=' <<>> disp abi
36 instance Parsec AbiDependency where
37 parsec = do
38 uid <- parsec
39 _ <- P.char '='
40 abi <- parsec
41 return (AbiDependency uid abi)
43 instance Text AbiDependency where
44 parse = do
45 uid <- parse
46 _ <- Parse.char '='
47 abi <- parse
48 return (AbiDependency uid abi)
50 instance Binary AbiDependency
52 instance NFData AbiDependency where rnf = genericRnf