ghc-9.0.1: The GHC API
Safe HaskellNone
LanguageHaskell2010

GHC.Unit.Types

Description

Unit & Module types

This module is used to resolve the loops between Unit and Module types (Module references a Unit and vice-versa).

Synopsis

Modules

data GenModule unit Source #

A generic module is a pair of a unit identifier and a ModuleName.

Constructors

Module 

Fields

Instances

Instances details
Functor GenModule # 
Instance details

Defined in GHC.Unit.Types

Methods

fmap :: (a -> b) -> GenModule a -> GenModule b Source #

(<$) :: a -> GenModule b -> GenModule a Source #

Outputable Module # 
Instance details

Defined in GHC.Unit.Types

Outputable InstantiatedModule # 
Instance details

Defined in GHC.Unit.Types

Outputable InstalledModule # 
Instance details

Defined in GHC.Unit.Types

Uniquable Module # 
Instance details

Defined in GHC.Unit.Types

Eq unit => Eq (GenModule unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

(==) :: GenModule unit -> GenModule unit -> Bool #

(/=) :: GenModule unit -> GenModule unit -> Bool #

Data unit => Data (GenModule unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GenModule unit -> c (GenModule unit) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (GenModule unit) Source #

toConstr :: GenModule unit -> Constr Source #

dataTypeOf :: GenModule unit -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (GenModule unit)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GenModule unit)) Source #

gmapT :: (forall b. Data b => b -> b) -> GenModule unit -> GenModule unit Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GenModule unit -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GenModule unit -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> GenModule unit -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> GenModule unit -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> GenModule unit -> m (GenModule unit) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GenModule unit -> m (GenModule unit) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GenModule unit -> m (GenModule unit) Source #

Ord unit => Ord (GenModule unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

compare :: GenModule unit -> GenModule unit -> Ordering #

(<) :: GenModule unit -> GenModule unit -> Bool #

(<=) :: GenModule unit -> GenModule unit -> Bool #

(>) :: GenModule unit -> GenModule unit -> Bool #

(>=) :: GenModule unit -> GenModule unit -> Bool #

max :: GenModule unit -> GenModule unit -> GenModule unit #

min :: GenModule unit -> GenModule unit -> GenModule unit #

NFData (GenModule a) # 
Instance details

Defined in GHC.Unit.Types

Methods

rnf :: GenModule a -> () Source #

Binary a => Binary (GenModule a) # 
Instance details

Defined in GHC.Unit.Types

type Module = GenModule Unit Source #

A Module is a pair of a Unit and a ModuleName.

type InstalledModule = GenModule UnitId Source #

A InstalledModule is a Module whose unit is identified with an UnitId.

moduleFreeHoles :: GenModule (GenUnit u) -> UniqDSet ModuleName Source #

Calculate the free holes of a Module. If this set is non-empty, this module was defined in an indefinite library that had required signatures.

If a module has free holes, that means that substitutions can operate on it; if it has no free holes, substituting over a module has no effect.

Units

data GenUnit uid Source #

A unit identifier identifies a (possibly partially) instantiated library. It is primarily used as part of Module, which in turn is used in Name, which is used to give names to entities when typechecking.

There are two possible forms for a Unit:

1) It can be a RealUnit, in which case we just have a DefUnitId that uniquely identifies some fully compiled, installed library we have on disk.

2) It can be an VirtUnit. When we are typechecking a library with missing holes, we may need to instantiate a library on the fly (in which case we don't have any on-disk representation.) In that case, you have an InstantiatedUnit, which explicitly records the instantiation, so that we can substitute over it.

Constructors

RealUnit !(Definite uid)

Installed definite unit (either a fully instantiated unit or a closed unit)

VirtUnit !(GenInstantiatedUnit uid)

Virtual unit instantiated on-the-fly. It may be definite if all the holes are instantiated but we don't have code objects for it.

HoleUnit

Fake hole unit

Instances

Instances details
Eq Unit # 
Instance details

Defined in GHC.Unit.Types

Methods

(==) :: Unit -> Unit -> Bool #

(/=) :: Unit -> Unit -> Bool #

Data Unit # 
Instance details

Defined in GHC.Unit.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Unit -> c Unit Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Unit Source #

toConstr :: Unit -> Constr Source #

dataTypeOf :: Unit -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Unit) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Unit) Source #

gmapT :: (forall b. Data b => b -> b) -> Unit -> Unit Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Unit -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Unit -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Unit -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Unit -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Unit -> m Unit Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Unit -> m Unit Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Unit -> m Unit Source #

Ord Unit # 
Instance details

Defined in GHC.Unit.Types

Methods

compare :: Unit -> Unit -> Ordering #

(<) :: Unit -> Unit -> Bool #

(<=) :: Unit -> Unit -> Bool #

(>) :: Unit -> Unit -> Bool #

(>=) :: Unit -> Unit -> Bool #

max :: Unit -> Unit -> Unit #

min :: Unit -> Unit -> Unit #

Show Unit # 
Instance details

Defined in GHC.Unit.Types

NFData Unit # 
Instance details

Defined in GHC.Unit.Types

Methods

rnf :: Unit -> () Source #

Outputable Unit # 
Instance details

Defined in GHC.Unit.Types

Outputable Module # 
Instance details

Defined in GHC.Unit.Types

Uniquable Unit # 
Instance details

Defined in GHC.Unit.Types

Uniquable Module # 
Instance details

Defined in GHC.Unit.Types

Binary Unit # 
Instance details

Defined in GHC.Unit.Types

newtype UnitId Source #

A UnitId identifies a built library in a database and is used to generate unique symbols, etc. It's usually of the form:

pkgname-1.2:libname+hash

These UnitId are provided to us via the -this-unit-id flag.

The library in question may be definite or indefinite; if it is indefinite, none of the holes have been filled (we never install partially instantiated libraries as we can cheaply instantiate them on-the-fly, cf VirtUnit). Put another way, an installed unit id is either fully instantiated, or not instantiated at all.

Constructors

UnitId 

Fields

  • unitIdFS :: FastString

    The full hashed unit identifier, including the component id and the hash.

Instances

Instances details
Eq Unit # 
Instance details

Defined in GHC.Unit.Types

Methods

(==) :: Unit -> Unit -> Bool #

(/=) :: Unit -> Unit -> Bool #

Eq UnitId # 
Instance details

Defined in GHC.Unit.Types

Methods

(==) :: UnitId -> UnitId -> Bool #

(/=) :: UnitId -> UnitId -> Bool #

Data Unit # 
Instance details

Defined in GHC.Unit.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Unit -> c Unit Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Unit Source #

toConstr :: Unit -> Constr Source #

dataTypeOf :: Unit -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Unit) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Unit) Source #

gmapT :: (forall b. Data b => b -> b) -> Unit -> Unit Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Unit -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Unit -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Unit -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Unit -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Unit -> m Unit Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Unit -> m Unit Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Unit -> m Unit Source #

Ord Unit # 
Instance details

Defined in GHC.Unit.Types

Methods

compare :: Unit -> Unit -> Ordering #

(<) :: Unit -> Unit -> Bool #

(<=) :: Unit -> Unit -> Bool #

(>) :: Unit -> Unit -> Bool #

(>=) :: Unit -> Unit -> Bool #

max :: Unit -> Unit -> Unit #

min :: Unit -> Unit -> Unit #

Ord UnitId # 
Instance details

Defined in GHC.Unit.Types

Show Unit # 
Instance details

Defined in GHC.Unit.Types

NFData Unit # 
Instance details

Defined in GHC.Unit.Types

Methods

rnf :: Unit -> () Source #

Outputable Unit # 
Instance details

Defined in GHC.Unit.Types

Outputable Module # 
Instance details

Defined in GHC.Unit.Types

Outputable UnitId # 
Instance details

Defined in GHC.Unit.Types

Outputable InstantiatedUnit # 
Instance details

Defined in GHC.Unit.Types

Outputable InstantiatedModule # 
Instance details

Defined in GHC.Unit.Types

Outputable InstalledModule # 
Instance details

Defined in GHC.Unit.Types

Uniquable Unit # 
Instance details

Defined in GHC.Unit.Types

Uniquable Module # 
Instance details

Defined in GHC.Unit.Types

Uniquable UnitId # 
Instance details

Defined in GHC.Unit.Types

Binary Unit # 
Instance details

Defined in GHC.Unit.Types

Binary UnitId # 
Instance details

Defined in GHC.Unit.Types

Binary InstantiatedUnit # 
Instance details

Defined in GHC.Unit.Types

data GenInstantiatedUnit unit Source #

An instantiated unit.

It identifies an indefinite library (with holes) that has been instantiated.

This unit may be indefinite or not (i.e. with remaining holes or not). If it is definite, we don't know if it has already been compiled and installed in a database. Nevertheless, we have a mechanism called "improvement" to try to match a fully instantiated unit with existing compiled and installed units: see Note [VirtUnit to RealUnit improvement].

An indefinite unit identifier pretty-prints to something like p[H=H,A=aimpl:A>] (p is the IndefUnitId, and the brackets enclose the module substitution).

Constructors

InstantiatedUnit 

Fields

type IndefUnitId = Indefinite UnitId Source #

An IndefUnitId is an UnitId with the invariant that it only refers to an indefinite library; i.e., one that can be instantiated.

type DefUnitId = Definite UnitId Source #

A DefUnitId is an UnitId with the invariant that it only refers to a definite library; i.e., one we have generated code for.

mkGenInstantiatedUnit :: (unit -> FastString) -> Indefinite unit -> GenInstantiations unit -> GenInstantiatedUnit unit Source #

Create a new GenInstantiatedUnit given an explicit module substitution.

mkInstantiatedUnit :: IndefUnitId -> Instantiations -> InstantiatedUnit Source #

Create a new InstantiatedUnit given an explicit module substitution.

mkGenVirtUnit :: (unit -> FastString) -> Indefinite unit -> [(ModuleName, GenModule (GenUnit unit))] -> GenUnit unit Source #

Smart constructor for instantiated GenUnit

mkVirtUnit :: IndefUnitId -> Instantiations -> Unit Source #

Smart constructor for VirtUnit

mapGenUnit :: (u -> v) -> (v -> FastString) -> GenUnit u -> GenUnit v Source #

Map over the unit type of a GenUnit

unitFreeModuleHoles :: GenUnit u -> UniqDSet ModuleName Source #

Retrieve the set of free module holes of a Unit.

fsToUnit :: FastString -> Unit Source #

Create a new simple unit identifier from a FastString. Internally, this is primarily used to specify wired-in unit identifiers.

toUnitId :: Unit -> UnitId Source #

Return the UnitId of the Unit. For on-the-fly instantiated units, return the UnitId of the indefinite unit this unit is an instance of.

virtualUnitId :: InstantiatedUnit -> UnitId Source #

Return the virtual UnitId of an on-the-fly instantiated unit.

stableUnitCmp :: Unit -> Unit -> Ordering Source #

Compares unit ids lexically, rather than by their Uniques

unitIsDefinite :: Unit -> Bool Source #

A Unit is definite if it has no free holes.

Unit Ids

Utils

newtype Definite unit Source #

A definite unit (i.e. without any free module hole)

Constructors

Definite 

Fields

Instances

Instances details
Functor Definite # 
Instance details

Defined in GHC.Unit.Types

Methods

fmap :: (a -> b) -> Definite a -> Definite b Source #

(<$) :: a -> Definite b -> Definite a Source #

Eq unit => Eq (Definite unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

(==) :: Definite unit -> Definite unit -> Bool #

(/=) :: Definite unit -> Definite unit -> Bool #

Ord unit => Ord (Definite unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

compare :: Definite unit -> Definite unit -> Ordering #

(<) :: Definite unit -> Definite unit -> Bool #

(<=) :: Definite unit -> Definite unit -> Bool #

(>) :: Definite unit -> Definite unit -> Bool #

(>=) :: Definite unit -> Definite unit -> Bool #

max :: Definite unit -> Definite unit -> Definite unit #

min :: Definite unit -> Definite unit -> Definite unit #

Outputable unit => Outputable (Definite unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

ppr :: Definite unit -> SDoc Source #

pprPrec :: Rational -> Definite unit -> SDoc Source #

Binary unit => Binary (Definite unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

put_ :: BinHandle -> Definite unit -> IO () Source #

put :: BinHandle -> Definite unit -> IO (Bin (Definite unit)) Source #

get :: BinHandle -> IO (Definite unit) Source #

data Indefinite unit Source #

Constructors

Indefinite 

Fields

Instances

Instances details
Functor Indefinite # 
Instance details

Defined in GHC.Unit.Types

Methods

fmap :: (a -> b) -> Indefinite a -> Indefinite b Source #

(<$) :: a -> Indefinite b -> Indefinite a Source #

Eq unit => Eq (Indefinite unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

(==) :: Indefinite unit -> Indefinite unit -> Bool #

(/=) :: Indefinite unit -> Indefinite unit -> Bool #

Ord unit => Ord (Indefinite unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

compare :: Indefinite unit -> Indefinite unit -> Ordering #

(<) :: Indefinite unit -> Indefinite unit -> Bool #

(<=) :: Indefinite unit -> Indefinite unit -> Bool #

(>) :: Indefinite unit -> Indefinite unit -> Bool #

(>=) :: Indefinite unit -> Indefinite unit -> Bool #

max :: Indefinite unit -> Indefinite unit -> Indefinite unit #

min :: Indefinite unit -> Indefinite unit -> Indefinite unit #

Outputable unit => Outputable (Indefinite unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

ppr :: Indefinite unit -> SDoc Source #

pprPrec :: Rational -> Indefinite unit -> SDoc Source #

Uniquable unit => Uniquable (Indefinite unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

getUnique :: Indefinite unit -> Unique Source #

Binary unit => Binary (Indefinite unit) # 
Instance details

Defined in GHC.Unit.Types

Methods

put_ :: BinHandle -> Indefinite unit -> IO () Source #

put :: BinHandle -> Indefinite unit -> IO (Bin (Indefinite unit)) Source #

get :: BinHandle -> IO (Indefinite unit) Source #

Wired-in units

mainUnitId :: UnitId Source #

This is the package Id for the current program. It is the default package Id if you don't specify a package name. We don't add this prefix to symbol names, since there can be only one main package per program.

Boot modules

data IsBootInterface Source #

Indicates whether a module name is referring to a boot interface (hs-boot file) or regular module (hs file). We need to treat boot modules specially when building compilation graphs, since they break cycles. Regular source files and signature files are treated equivalently.

Constructors

NotBoot 
IsBoot 

Instances

Instances details
Eq IsBootInterface # 
Instance details

Defined in GHC.Unit.Types

Data IsBootInterface # 
Instance details

Defined in GHC.Unit.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> IsBootInterface -> c IsBootInterface Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c IsBootInterface Source #

toConstr :: IsBootInterface -> Constr Source #

dataTypeOf :: IsBootInterface -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c IsBootInterface) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IsBootInterface) Source #

gmapT :: (forall b. Data b => b -> b) -> IsBootInterface -> IsBootInterface Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IsBootInterface -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IsBootInterface -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> IsBootInterface -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> IsBootInterface -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> IsBootInterface -> m IsBootInterface Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> IsBootInterface -> m IsBootInterface Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> IsBootInterface -> m IsBootInterface Source #

Ord IsBootInterface # 
Instance details

Defined in GHC.Unit.Types

Show IsBootInterface # 
Instance details

Defined in GHC.Unit.Types

Binary IsBootInterface # 
Instance details

Defined in GHC.Unit.Types

data GenWithIsBoot mod Source #

This data type just pairs a value mod with an IsBootInterface flag. In practice, mod is usually a Module or ModuleName'.

Constructors

GWIB 

Instances

Instances details
Functor GenWithIsBoot # 
Instance details

Defined in GHC.Unit.Types

Methods

fmap :: (a -> b) -> GenWithIsBoot a -> GenWithIsBoot b Source #

(<$) :: a -> GenWithIsBoot b -> GenWithIsBoot a Source #

Foldable GenWithIsBoot # 
Instance details

Defined in GHC.Unit.Types

Methods

fold :: Monoid m => GenWithIsBoot m -> m Source #

foldMap :: Monoid m => (a -> m) -> GenWithIsBoot a -> m Source #

foldMap' :: Monoid m => (a -> m) -> GenWithIsBoot a -> m Source #

foldr :: (a -> b -> b) -> b -> GenWithIsBoot a -> b Source #

foldr' :: (a -> b -> b) -> b -> GenWithIsBoot a -> b Source #

foldl :: (b -> a -> b) -> b -> GenWithIsBoot a -> b Source #

foldl' :: (b -> a -> b) -> b -> GenWithIsBoot a -> b Source #

foldr1 :: (a -> a -> a) -> GenWithIsBoot a -> a Source #

foldl1 :: (a -> a -> a) -> GenWithIsBoot a -> a Source #

toList :: GenWithIsBoot a -> [a] Source #

null :: GenWithIsBoot a -> Bool Source #

length :: GenWithIsBoot a -> Int Source #

elem :: Eq a => a -> GenWithIsBoot a -> Bool Source #

maximum :: Ord a => GenWithIsBoot a -> a Source #

minimum :: Ord a => GenWithIsBoot a -> a Source #

sum :: Num a => GenWithIsBoot a -> a Source #

product :: Num a => GenWithIsBoot a -> a Source #

Traversable GenWithIsBoot # 
Instance details

Defined in GHC.Unit.Types

Methods

traverse :: Applicative f => (a -> f b) -> GenWithIsBoot a -> f (GenWithIsBoot b) Source #

sequenceA :: Applicative f => GenWithIsBoot (f a) -> f (GenWithIsBoot a) Source #

mapM :: Monad m => (a -> m b) -> GenWithIsBoot a -> m (GenWithIsBoot b) Source #

sequence :: Monad m => GenWithIsBoot (m a) -> m (GenWithIsBoot a) Source #

Eq mod => Eq (GenWithIsBoot mod) # 
Instance details

Defined in GHC.Unit.Types

Methods

(==) :: GenWithIsBoot mod -> GenWithIsBoot mod -> Bool #

(/=) :: GenWithIsBoot mod -> GenWithIsBoot mod -> Bool #

Ord mod => Ord (GenWithIsBoot mod) # 
Instance details

Defined in GHC.Unit.Types

Show mod => Show (GenWithIsBoot mod) # 
Instance details

Defined in GHC.Unit.Types

Outputable a => Outputable (GenWithIsBoot a) # 
Instance details

Defined in GHC.Unit.Types

Binary a => Binary (GenWithIsBoot a) # 
Instance details

Defined in GHC.Unit.Types