make LTS branch pre-releases
[cabal.git] / Cabal-syntax / src / Distribution / Types / AbiDependency.hs
blob2f380d15af211b7237865d401daf84a7fe7f3123
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
4 module Distribution.Types.AbiDependency where
6 import Distribution.Compat.Prelude
7 import Prelude ()
9 import Distribution.Parsec
10 import Distribution.Pretty
12 import qualified Distribution.Compat.CharParsing as P
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, Typeable)
32 instance Pretty AbiDependency where
33 pretty (AbiDependency uid abi) =
34 pretty uid <<>> Disp.char '=' <<>> pretty 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 Binary AbiDependency
44 instance Structured AbiDependency
45 instance NFData AbiDependency where rnf = genericRnf