Distribution.Types.Dependency

Cabal-3.6.0.0: A framework for packaging Haskell software

Safe Haskell | Safe-Inferred
Language | Haskell2010

Distribution.Types.Dependency

Synopsis

- data Dependency = Dependency PackageName VersionRange (NonEmptySet LibraryName)
- mkDependency :: PackageName -> VersionRange -> NonEmptySet LibraryName -> Dependency
- depPkgName :: Dependency -> PackageName
- depVerRange :: Dependency -> VersionRange
- depLibraries :: Dependency -> NonEmptySet LibraryName
- simplifyDependency :: Dependency -> Dependency
- mainLibSet :: NonEmptySet LibraryName

# Documentation

data Dependency Source #

Describes a dependency on a source package (API)

Invariant: package name does not appear as `LSubLibName` in set of library names.

Constructors

Dependency PackageName VersionRange (NonEmptySet LibraryName) | The set of libraries required from the package. Only the selected libraries will be built. It does not affect the cabal-install solver yet.

#### Instances

Instances details

Parsec Dependency Source # |
    >>> simpleParsec "mylib:sub" :: Maybe Dependency
    Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub") :| [])))
    >>> simpleParsec "mylib:{sub1,sub2}" :: Maybe Dependency
    Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub1") :| [LSubLibName (UnqualComponentName "sub2")])))
    >>> simpleParsec "mylib:{ sub1 , sub2 }" :: Maybe Dependency
    Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub1") :| [LSubLibName (UnqualComponentName "sub2")])))
    >>> simpleParsec "mylib:{ sub1 , sub2 } ^>= 42" :: Maybe Dependency
    Just (Dependency (PackageName "mylib") (MajorBoundVersion (mkVersion [42])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub1") :| [LSubLibName (UnqualComponentName "sub2")])))
    >>> simpleParsec "mylib:{ } ^>= 42" :: Maybe Dependency
    Nothing
    >>> traverse_ print (map simpleParsec ["mylib:mylib", "mylib:{mylib}", "mylib:{mylib,sublib}" ] :: [Maybe Dependency])
    Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LMainLibName :| [])))
    Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LMainLibName :| [])))
    Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LMainLibName :| [LSubLibName (UnqualComponentName "sublib")])))
Spaces around colon are not allowed:
    >>> map simpleParsec ["mylib: sub", "mylib :sub", "mylib: {sub1,sub2}", "mylib :{sub1,sub2}"] :: [Maybe Dependency]
    [Nothing,Nothing,Nothing,Nothing]
Sublibrary syntax is accepted since `cabal-version: 3.0`
    >>> map (`simpleParsec'` "mylib:sub") [CabalSpecV2_4, CabalSpecV3_0] :: [Maybe Dependency]
    [Nothing,Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub") :| [])))]
Instance details Defined in Distribution.Types.Dependency Methods parsec :: CabalParsing m => m Dependency Source #
Pretty Dependency Source # |
    >>> prettyShow $ Dependency "pkg" anyVersion mainLibSet
    "pkg"
    >>> prettyShow $ Dependency "pkg" anyVersion $ NES.insert (LSubLibName "sublib") mainLibSet
    "pkg:{pkg, sublib}"
    >>> prettyShow $ Dependency "pkg" anyVersion $ NES.singleton (LSubLibName "sublib")
    "pkg:sublib"
    >>> prettyShow $ Dependency "pkg" anyVersion $ NES.insert (LSubLibName "sublib-b") $ NES.singleton (LSubLibName "sublib-a")
    "pkg:{sublib-a, sublib-b}"
Instance details Defined in Distribution.Types.Dependency Methods pretty :: Dependency -> Doc Source # prettyVersioned :: CabalSpecVersion -> Dependency -> Doc Source #
Structured Dependency Source # |
Instance details Defined in Distribution.Types.Dependency Methods structure :: Proxy Dependency -> Structure Source # structureHash' :: Tagged Dependency MD5
Data Dependency Source # |
Instance details Defined in Distribution.Types.Dependency Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Dependency -> c Dependency Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Dependency Source # toConstr :: Dependency -> Constr Source # dataTypeOf :: Dependency -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Dependency) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Dependency) Source # gmapT :: (forall b. Data b => b -> b) -> Dependency -> Dependency Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Dependency -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Dependency -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Dependency -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Dependency -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Dependency -> m Dependency Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Dependency -> m Dependency Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Dependency -> m Dependency Source #
Generic Dependency Source # |
Instance details Defined in Distribution.Types.Dependency Associated Types type Rep Dependency :: Type -> Type Source # Methods from :: Dependency -> Rep Dependency x Source # to :: Rep Dependency x -> Dependency Source #
Read Dependency Source # |
Instance details Defined in Distribution.Types.Dependency Methods readsPrec :: Int -> ReadS Dependency Source # readList :: ReadS [Dependency] Source # readPrec :: ReadPrec Dependency Source # readListPrec :: ReadPrec [Dependency] Source #
Show Dependency Source # |
Instance details Defined in Distribution.Types.Dependency Methods showsPrec :: Int -> Dependency -> ShowS Source # show :: Dependency -> String Source # showList :: [Dependency] -> ShowS Source #
Binary Dependency Source # |
Instance details Defined in Distribution.Types.Dependency Methods put :: Dependency -> Put Source # get :: Get Dependency Source # putList :: [Dependency] -> Put Source #
NFData Dependency Source # |
Instance details Defined in Distribution.Types.Dependency Methods rnf :: Dependency -> () Source #
Eq Dependency Source # |
Instance details Defined in Distribution.Types.Dependency Methods (==) :: Dependency -> Dependency -> Bool # (/=) :: Dependency -> Dependency -> Bool #
type Rep Dependency Source # |
Instance details Defined in Distribution.Types.Dependency type Rep Dependency = D1 ('MetaData "Dependency" "Distribution.Types.Dependency" "Cabal-3.6.0.0" 'False) (C1 ('MetaCons "Dependency" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PackageName) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 VersionRange) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmptySet LibraryName)))))

mkDependency :: PackageName -> VersionRange -> NonEmptySet LibraryName -> Dependency Source #

Smart constructor of `Dependency`.

If `PackageName` is appears as `LSubLibName` in a set of sublibraries, it is automatically converted to `LMainLibName`.

Since: Cabal-3.4.0.0

depPkgName :: Dependency -> PackageName Source #

depVerRange :: Dependency -> VersionRange Source #

depLibraries :: Dependency -> NonEmptySet LibraryName Source #

simplifyDependency :: Dependency -> Dependency Source #

Simplify the `VersionRange` expression in a `Dependency`. See `simplifyVersionRange`.

mainLibSet :: NonEmptySet LibraryName Source #

Library set with main library.

Since: Cabal-3.4.0.0