Cabal-2.2.0.1: A framework for packaging Haskell software

Safe HaskellNone
LanguageHaskell2010

Distribution.Backpack

Contents

Description

This module defines the core data types for Backpack. For more details, see:

https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst

Synopsis

OpenUnitId

data OpenUnitId #

An OpenUnitId describes a (possibly partially) instantiated Backpack component, with a description of how the holes are filled in. Unlike OpenUnitId, the ModuleSubst is kept in a structured form that allows for substitution (which fills in holes.) This form of unit cannot be installed. It must first be converted to a UnitId.

In the absence of Backpack, there are no holes to fill, so any such component always has an empty module substitution; thus we can lossly represent it as an 'OpenUnitId uid'.

For a source component using Backpack, however, there is more structure as components may be parametrized over some signatures, and these "holes" may be partially or wholly filled.

OpenUnitId plays an important role when we are mix-in linking, and is recorded to the installed packaged database for indefinite packages; however, for compiled packages that are fully instantiated, we instantiate OpenUnitId into UnitId.

For more details see the Backpack spec https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst

Constructors

IndefFullUnitId ComponentId OpenModuleSubst

Identifies a component which may have some unfilled holes; specifying its ComponentId and its OpenModuleSubst. TODO: Invariant that OpenModuleSubst is non-empty? See also the Text instance.

DefiniteUnitId DefUnitId

Identifies a fully instantiated component, which has been compiled and abbreviated as a hash. The embedded UnitId MUST NOT be for an indefinite component; an OpenUnitId is guaranteed not to have any holes.

Instances
Eq OpenUnitId # 
Instance details
Data OpenUnitId # 
Instance details

Methods

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

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

toConstr :: OpenUnitId -> Constr #

dataTypeOf :: OpenUnitId -> DataType #

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

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

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

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

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

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

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

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

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

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

Ord OpenUnitId # 
Instance details
Read OpenUnitId # 
Instance details
Show OpenUnitId # 
Instance details
Generic OpenUnitId # 
Instance details

Associated Types

type Rep OpenUnitId :: * -> * #

Binary OpenUnitId # 
Instance details
NFData OpenUnitId # 
Instance details

Methods

rnf :: OpenUnitId -> () #

Pretty OpenUnitId # 
Instance details

Methods

pretty :: OpenUnitId -> Doc #

Parsec OpenUnitId #
>>> eitherParsec "foobar" :: Either String OpenUnitId
Right (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "foobar"}))
>>> eitherParsec "foo[Str=text-1.2.3:Data.Text.Text]" :: Either String OpenUnitId
Right (IndefFullUnitId (ComponentId "foo") (fromList [(ModuleName ["Str"],OpenModule (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "text-1.2.3"})) (ModuleName ["Data","Text","Text"]))]))
Instance details

Methods

parsec :: CabalParsing m => m OpenUnitId #

Text OpenUnitId # 
Instance details
ModSubst OpenUnitId # 
Instance details
type Rep OpenUnitId # 
Instance details

openUnitIdFreeHoles :: OpenUnitId -> Set ModuleName #

Get the set of holes (ModuleVar) embedded in a UnitId.

mkOpenUnitId :: UnitId -> ComponentId -> OpenModuleSubst -> OpenUnitId #

Safe constructor from a UnitId. The only way to do this safely is if the instantiation is provided.

DefUnitId

data DefUnitId #

A UnitId for a definite package. The DefUnitId invariant says that a UnitId identified this way is definite; i.e., it has no unfilled holes.

Instances
Eq DefUnitId # 
Instance details
Data DefUnitId # 
Instance details

Methods

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

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

toConstr :: DefUnitId -> Constr #

dataTypeOf :: DefUnitId -> DataType #

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

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

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

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

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

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

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

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

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

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

Ord DefUnitId # 
Instance details
Read DefUnitId # 
Instance details
Show DefUnitId # 
Instance details
Generic DefUnitId # 
Instance details

Associated Types

type Rep DefUnitId :: * -> * #

Binary DefUnitId # 
Instance details
NFData DefUnitId # 
Instance details

Methods

rnf :: DefUnitId -> () #

Pretty DefUnitId # 
Instance details

Methods

pretty :: DefUnitId -> Doc #

Parsec DefUnitId # 
Instance details

Methods

parsec :: CabalParsing m => m DefUnitId #

Text DefUnitId # 
Instance details
type Rep DefUnitId # 
Instance details
type Rep DefUnitId = D1 (MetaData "DefUnitId" "Distribution.Types.UnitId" "Cabal-2.2.0.1-JS0vobxWxH7sbYKd0omMO" True) (C1 (MetaCons "DefUnitId" PrefixI True) (S1 (MetaSel (Just "unDefUnitId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 UnitId)))

mkDefUnitId :: ComponentId -> Map ModuleName Module -> DefUnitId #

Create a DefUnitId from a ComponentId and an instantiation with no holes.

OpenModule

data OpenModule #

Unlike a Module, an OpenModule is either an ordinary module from some unit, OR an OpenModuleVar, representing a hole that needs to be filled in. Substitutions are over module variables.

Instances
Eq OpenModule # 
Instance details
Data OpenModule # 
Instance details

Methods

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

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

toConstr :: OpenModule -> Constr #

dataTypeOf :: OpenModule -> DataType #

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

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

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

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

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

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

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

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

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

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

Ord OpenModule # 
Instance details
Read OpenModule # 
Instance details
Show OpenModule # 
Instance details
Generic OpenModule # 
Instance details

Associated Types

type Rep OpenModule :: * -> * #

Binary OpenModule # 
Instance details
NFData OpenModule # 
Instance details

Methods

rnf :: OpenModule -> () #

Pretty OpenModule # 
Instance details

Methods

pretty :: OpenModule -> Doc #

Parsec OpenModule #
>>> eitherParsec "Includes2-0.1.0.0-inplace-mysql:Database.MySQL" :: Either String OpenModule
Right (OpenModule (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "Includes2-0.1.0.0-inplace-mysql"})) (ModuleName ["Database","MySQL"]))
Instance details

Methods

parsec :: CabalParsing m => m OpenModule #

Text OpenModule # 
Instance details
ModSubst OpenModule # 
Instance details
type Rep OpenModule # 
Instance details

openModuleFreeHoles :: OpenModule -> Set ModuleName #

Get the set of holes (ModuleVar) embedded in a Module.

OpenModuleSubst

type OpenModuleSubst = Map ModuleName OpenModule #

An explicit substitution on modules.

NB: These substitutions are NOT idempotent, for example, a valid substitution is (A -> B, B -> A).

dispOpenModuleSubst :: OpenModuleSubst -> Doc #

Pretty-print the entries of a module substitution, suitable for embedding into a OpenUnitId or passing to GHC via --instantiate-with.

dispOpenModuleSubstEntry :: (ModuleName, OpenModule) -> Doc #

Pretty-print a single entry of a module substitution.

parseOpenModuleSubst :: ReadP r OpenModuleSubst #

Inverse to dispModSubst.

parseOpenModuleSubstEntry :: ReadP r (ModuleName, OpenModule) #

Inverse to dispModSubstEntry.

parsecOpenModuleSubst :: CabalParsing m => m OpenModuleSubst #

Inverse to dispModSubst.

Since: 2.2

parsecOpenModuleSubstEntry :: CabalParsing m => m (ModuleName, OpenModule) #

Inverse to dispModSubstEntry.

Since: 2.2

openModuleSubstFreeHoles :: OpenModuleSubst -> Set ModuleName #

Get the set of holes (ModuleVar) embedded in a OpenModuleSubst. This is NOT the domain of the substitution.

Conversions to UnitId

abstractUnitId :: OpenUnitId -> UnitId #

When typechecking, we don't demand that a freshly instantiated IndefFullUnitId be compiled; instead, we just depend on the installed indefinite unit installed at the ComponentId.

hashModuleSubst :: Map ModuleName Module -> Maybe String #

Take a module substitution and hash it into a string suitable for UnitId. Note that since this takes Module, not OpenModule, you are responsible for recursively converting OpenModule into Module. See also Distribution.Backpack.ReadyComponent.