Safe Haskell | Ignore |
---|---|
Language | Haskell2010 |
The home unit is the unit (i.e. compiled package) that contains the module we are compiling/typechecking.
Synopsis
- data GenHomeUnit u
- = DefiniteHomeUnit UnitId (Maybe (u, GenInstantiations u))
- | IndefiniteHomeUnit UnitId (GenInstantiations u)
- type HomeUnit = GenHomeUnit UnitId
- homeUnitId :: GenHomeUnit u -> UnitId
- homeUnitInstantiations :: GenHomeUnit u -> GenInstantiations u
- homeUnitInstanceOf :: HomeUnit -> UnitId
- homeUnitInstanceOfMaybe :: GenHomeUnit u -> Maybe u
- homeUnitAsUnit :: HomeUnit -> Unit
- homeUnitMap :: IsUnitId v => (u -> v) -> GenHomeUnit u -> GenHomeUnit v
- isHomeUnitIndefinite :: GenHomeUnit u -> Bool
- isHomeUnitDefinite :: GenHomeUnit u -> Bool
- isHomeUnitInstantiating :: GenHomeUnit u -> Bool
- isHomeUnit :: HomeUnit -> Unit -> Bool
- isHomeUnitId :: GenHomeUnit u -> UnitId -> Bool
- isHomeUnitInstanceOf :: HomeUnit -> UnitId -> Bool
- isHomeModule :: HomeUnit -> Module -> Bool
- isHomeInstalledModule :: GenHomeUnit u -> InstalledModule -> Bool
- notHomeUnitId :: Maybe (GenHomeUnit u) -> UnitId -> Bool
- notHomeModule :: HomeUnit -> Module -> Bool
- notHomeModuleMaybe :: Maybe HomeUnit -> Module -> Bool
- notHomeInstalledModule :: GenHomeUnit u -> InstalledModule -> Bool
- notHomeInstalledModuleMaybe :: Maybe (GenHomeUnit u) -> InstalledModule -> Bool
- mkHomeModule :: HomeUnit -> ModuleName -> Module
- mkHomeInstalledModule :: GenHomeUnit u -> ModuleName -> InstalledModule
- homeModuleInstantiation :: Maybe HomeUnit -> Module -> Module
- homeModuleNameInstantiation :: HomeUnit -> ModuleName -> Module
Documentation
data GenHomeUnit u Source #
Information about the home unit (i.e., the until that will contain the modules we are compiling)
The unit identifier of the instantiating units is left open to allow
switching from UnitKey (what is provided by the user) to UnitId (internal
unit identifier) with homeUnitMap
.
TODO: this isn't implemented yet. UnitKeys are still converted too early into UnitIds in GHC.Unit.State.readUnitDataBase
DefiniteHomeUnit UnitId (Maybe (u, GenInstantiations u)) | Definite home unit (i.e. that we can compile). Nothing: not an instantiated unit Just (i,insts): made definite by instantiating "i" with "insts" |
IndefiniteHomeUnit UnitId (GenInstantiations u) | Indefinite home unit (i.e. that we can only typecheck) All the holes are instantiated with fake modules from the Hole unit. See Note [Representation of module/name variables] in GHC.Unit |
type HomeUnit = GenHomeUnit UnitId Source #
homeUnitId :: GenHomeUnit u -> UnitId Source #
Return home unit id
homeUnitInstantiations :: GenHomeUnit u -> GenInstantiations u Source #
Return home unit instantiations
homeUnitInstanceOf :: HomeUnit -> UnitId Source #
Return the unit id of the unit that is instantiated by the home unit.
E.g. if home unit = q[A=p:B,...] we return q.
If the home unit is not an instance of another unit, we return its own unit id (it is an instance of itself if you will).
homeUnitInstanceOfMaybe :: GenHomeUnit u -> Maybe u Source #
Return the unit id of the unit that is instantiated by the home unit.
E.g. if home unit = q[A=p:B,...] we return (Just q).
If the home unit is not an instance of another unit, we return Nothing.
homeUnitAsUnit :: HomeUnit -> Unit Source #
Return the home unit as a normal unit.
We infer from the home unit itself the kind of unit we create:
1. If the home unit is definite, we must be compiling so we return a real
unit. The definite home unit may be the result of a unit instantiation,
say `p = q[A=r:X]`. In this case we could have returned a virtual unit
`q[A=r:X]` but it's not what the clients of this function expect,
especially because p
is lost when we do this. The unit id of a virtual
unit is made up internally so `unitId(q[A=r:X])` is not equal to p
.
- If the home unit is indefinite we can only create a virtual unit from it. It's ok because we must be only typechecking the home unit so we won't produce any code object that rely on the unit id of this virtual unit.
homeUnitMap :: IsUnitId v => (u -> v) -> GenHomeUnit u -> GenHomeUnit v Source #
Map over the unit identifier for instantiating units
Predicates
isHomeUnitIndefinite :: GenHomeUnit u -> Bool Source #
Test if we are type-checking an indefinite unit
(if it is not, we should never use on-the-fly renaming)
isHomeUnitDefinite :: GenHomeUnit u -> Bool Source #
Test if we are compiling a definite unit
(if it is, we should never use on-the-fly renaming)
isHomeUnitInstantiating :: GenHomeUnit u -> Bool Source #
Test if we are compiling by instantiating a definite unit
isHomeUnitId :: GenHomeUnit u -> UnitId -> Bool Source #
Test if the unit-id is the home unit-id
isHomeUnitInstanceOf :: HomeUnit -> UnitId -> Bool Source #
Test if the home unit is an instance of the given unit-id
isHomeInstalledModule :: GenHomeUnit u -> InstalledModule -> Bool Source #
Test if the module comes from the home unit
notHomeUnitId :: Maybe (GenHomeUnit u) -> UnitId -> Bool Source #
Test if the unit-id is not the home unit-id
notHomeModule :: HomeUnit -> Module -> Bool Source #
Test if a module doesn't come from the given home unit
notHomeModuleMaybe :: Maybe HomeUnit -> Module -> Bool Source #
Test if a module doesn't come from the given home unit
notHomeInstalledModule :: GenHomeUnit u -> InstalledModule -> Bool Source #
Test if a module doesn't come from the given home unit
notHomeInstalledModuleMaybe :: Maybe (GenHomeUnit u) -> InstalledModule -> Bool Source #
Test if a module doesn't come from the given home unit
Helpers
mkHomeModule :: HomeUnit -> ModuleName -> Module Source #
Make a module in home unit
mkHomeInstalledModule :: GenHomeUnit u -> ModuleName -> InstalledModule Source #
Make a module in home unit
homeModuleInstantiation :: Maybe HomeUnit -> Module -> Module Source #
Return the module that is used to instantiate the given home module.
If the given module isn't a module hole, return the actual home module.
E.g., the instantiating module of p:A
in p[A=q[]:B]
is q[]:B
.
the instantiating module of r:A
in p[A=q[]:B]
is r:A
.
the instantiating module of p:A
in p
is p:A
.
the instantiating module of r:A
in p
is r:A
.
homeModuleNameInstantiation :: HomeUnit -> ModuleName -> Module Source #
Return the module that is used to instantiate the given home module name. If the ModuleName doesn't refer to a signature, return the actual home module.
E.g., the instantiating module of A
in p[A=q[]:B]
is q[]:B
.
the instantiating module of A
in p
is p:A
.