make LTS branch pre-releases
[cabal.git] / Cabal-syntax / src / Distribution / Types / Module.hs
blobe9febeff0704242ba937b3fc137cdaa96413ef26
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
5 module Distribution.Types.Module
6 ( Module (..)
7 ) where
9 import Distribution.Compat.Prelude
10 import Prelude ()
12 import qualified Distribution.Compat.CharParsing as P
13 import Distribution.ModuleName
14 import Distribution.Parsec
15 import Distribution.Pretty
16 import Distribution.Types.UnitId
17 import qualified Text.PrettyPrint as Disp
19 -- | A module identity uniquely identifies a Haskell module by
20 -- qualifying a 'ModuleName' with the 'UnitId' which defined
21 -- it. This type distinguishes between two packages
22 -- which provide a module with the same name, or a module
23 -- from the same package compiled with different dependencies.
24 -- There are a few cases where Cabal needs to know about
25 -- module identities, e.g., when writing out reexported modules in
26 -- the 'InstalledPackageInfo'.
27 data Module
28 = Module DefUnitId ModuleName
29 deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)
31 instance Binary Module
32 instance Structured Module
34 instance Pretty Module where
35 pretty (Module uid mod_name) =
36 pretty uid <<>> Disp.text ":" <<>> pretty mod_name
38 instance Parsec Module where
39 parsec = do
40 uid <- parsec
41 _ <- P.char ':'
42 mod_name <- parsec
43 return (Module uid mod_name)
45 instance NFData Module where
46 rnf (Module uid mod_name) = rnf uid `seq` rnf mod_name