Cabal-3.4.1.0: A framework for packaging Haskell software
Safe HaskellSafe-Inferred
LanguageHaskell2010

Distribution.Types.CondTree

Synopsis

Documentation

data CondTree v c a Source #

A CondTree is used to represent the conditional structure of a Cabal file, reflecting a syntax element subject to constraints, and then any number of sub-elements which may be enabled subject to some condition. Both a and c are usually Monoids.

To be more concrete, consider the following fragment of a Cabal file:

build-depends: base >= 4.0
if flag(extra)
    build-depends: base >= 4.2

One way to represent this is to have CondTree ConfVar [Dependency] BuildInfo. Here, condTreeData represents the actual fields which are not behind any conditional, while condTreeComponents recursively records any further fields which are behind a conditional. condTreeConstraints records the constraints (in this case, base >= 4.0) which would be applied if you use this syntax; in general, this is derived off of targetBuildInfo (perhaps a good refactoring would be to convert this into an opaque type, with a smart constructor that pre-computes the dependencies.)

Constructors

CondNode 

Instances

Instances details
Foldable (CondTree v c) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

fold :: Monoid m => CondTree v c m -> m Source #

foldMap :: Monoid m => (a -> m) -> CondTree v c a -> m Source #

foldMap' :: Monoid m => (a -> m) -> CondTree v c a -> m Source #

foldr :: (a -> b -> b) -> b -> CondTree v c a -> b Source #

foldr' :: (a -> b -> b) -> b -> CondTree v c a -> b Source #

foldl :: (b -> a -> b) -> b -> CondTree v c a -> b Source #

foldl' :: (b -> a -> b) -> b -> CondTree v c a -> b Source #

foldr1 :: (a -> a -> a) -> CondTree v c a -> a Source #

foldl1 :: (a -> a -> a) -> CondTree v c a -> a Source #

toList :: CondTree v c a -> [a] Source #

null :: CondTree v c a -> Bool Source #

length :: CondTree v c a -> Int Source #

elem :: Eq a => a -> CondTree v c a -> Bool Source #

maximum :: Ord a => CondTree v c a -> a Source #

minimum :: Ord a => CondTree v c a -> a Source #

sum :: Num a => CondTree v c a -> a Source #

product :: Num a => CondTree v c a -> a Source #

Traversable (CondTree v c) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

traverse :: Applicative f => (a -> f b) -> CondTree v c a -> f (CondTree v c b) Source #

sequenceA :: Applicative f => CondTree v c (f a) -> f (CondTree v c a) Source #

mapM :: Monad m => (a -> m b) -> CondTree v c a -> m (CondTree v c b) Source #

sequence :: Monad m => CondTree v c (m a) -> m (CondTree v c a) Source #

Functor (CondTree v c) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

fmap :: (a -> b) -> CondTree v c a -> CondTree v c b Source #

(<$) :: a -> CondTree v c b -> CondTree v c a Source #

(Structured v, Structured c, Structured a) => Structured (CondTree v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

structure :: Proxy (CondTree v c a) -> Structure Source #

structureHash' :: Tagged (CondTree v c a) MD5

(Data v, Data c, Data a) => Data (CondTree v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

gfoldl :: (forall d b. Data d => c0 (d -> b) -> d -> c0 b) -> (forall g. g -> c0 g) -> CondTree v c a -> c0 (CondTree v c a) Source #

gunfold :: (forall b r. Data b => c0 (b -> r) -> c0 r) -> (forall r. r -> c0 r) -> Constr -> c0 (CondTree v c a) Source #

toConstr :: CondTree v c a -> Constr Source #

dataTypeOf :: CondTree v c a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c0 (t d)) -> Maybe (c0 (CondTree v c a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c0 (t d e)) -> Maybe (c0 (CondTree v c a)) Source #

gmapT :: (forall b. Data b => b -> b) -> CondTree v c a -> CondTree v c a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CondTree v c a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CondTree v c a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CondTree v c a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CondTree v c a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CondTree v c a -> m (CondTree v c a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CondTree v c a -> m (CondTree v c a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CondTree v c a -> m (CondTree v c a) Source #

Generic (CondTree v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Associated Types

type Rep (CondTree v c a) :: Type -> Type Source #

Methods

from :: CondTree v c a -> Rep (CondTree v c a) x Source #

to :: Rep (CondTree v c a) x -> CondTree v c a Source #

(Show a, Show c, Show v) => Show (CondTree v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

showsPrec :: Int -> CondTree v c a -> ShowS Source #

show :: CondTree v c a -> String Source #

showList :: [CondTree v c a] -> ShowS Source #

(Binary v, Binary c, Binary a) => Binary (CondTree v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

put :: CondTree v c a -> Put Source #

get :: Get (CondTree v c a) Source #

putList :: [CondTree v c a] -> Put Source #

(NFData v, NFData c, NFData a) => NFData (CondTree v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

rnf :: CondTree v c a -> () Source #

(Eq a, Eq c, Eq v) => Eq (CondTree v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

(==) :: CondTree v c a -> CondTree v c a -> Bool #

(/=) :: CondTree v c a -> CondTree v c a -> Bool #

type Rep (CondTree v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

type Rep (CondTree v c a) = D1 ('MetaData "CondTree" "Distribution.Types.CondTree" "Cabal-3.4.1.0" 'False) (C1 ('MetaCons "CondNode" 'PrefixI 'True) (S1 ('MetaSel ('Just "condTreeData") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: (S1 ('MetaSel ('Just "condTreeConstraints") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 c) :*: S1 ('MetaSel ('Just "condTreeComponents") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [CondBranch v c a]))))

data CondBranch v c a Source #

A CondBranch represents a conditional branch, e.g., if flag(foo) on some syntax a. It also has an optional false branch.

Instances

Instances details
Foldable (CondBranch v c) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

fold :: Monoid m => CondBranch v c m -> m Source #

foldMap :: Monoid m => (a -> m) -> CondBranch v c a -> m Source #

foldMap' :: Monoid m => (a -> m) -> CondBranch v c a -> m Source #

foldr :: (a -> b -> b) -> b -> CondBranch v c a -> b Source #

foldr' :: (a -> b -> b) -> b -> CondBranch v c a -> b Source #

foldl :: (b -> a -> b) -> b -> CondBranch v c a -> b Source #

foldl' :: (b -> a -> b) -> b -> CondBranch v c a -> b Source #

foldr1 :: (a -> a -> a) -> CondBranch v c a -> a Source #

foldl1 :: (a -> a -> a) -> CondBranch v c a -> a Source #

toList :: CondBranch v c a -> [a] Source #

null :: CondBranch v c a -> Bool Source #

length :: CondBranch v c a -> Int Source #

elem :: Eq a => a -> CondBranch v c a -> Bool Source #

maximum :: Ord a => CondBranch v c a -> a Source #

minimum :: Ord a => CondBranch v c a -> a Source #

sum :: Num a => CondBranch v c a -> a Source #

product :: Num a => CondBranch v c a -> a Source #

Traversable (CondBranch v c) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

traverse :: Applicative f => (a -> f b) -> CondBranch v c a -> f (CondBranch v c b) Source #

sequenceA :: Applicative f => CondBranch v c (f a) -> f (CondBranch v c a) Source #

mapM :: Monad m => (a -> m b) -> CondBranch v c a -> m (CondBranch v c b) Source #

sequence :: Monad m => CondBranch v c (m a) -> m (CondBranch v c a) Source #

Functor (CondBranch v c) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

fmap :: (a -> b) -> CondBranch v c a -> CondBranch v c b Source #

(<$) :: a -> CondBranch v c b -> CondBranch v c a Source #

(Structured v, Structured c, Structured a) => Structured (CondBranch v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

structure :: Proxy (CondBranch v c a) -> Structure Source #

structureHash' :: Tagged (CondBranch v c a) MD5

(Data v, Data c, Data a) => Data (CondBranch v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

gfoldl :: (forall d b. Data d => c0 (d -> b) -> d -> c0 b) -> (forall g. g -> c0 g) -> CondBranch v c a -> c0 (CondBranch v c a) Source #

gunfold :: (forall b r. Data b => c0 (b -> r) -> c0 r) -> (forall r. r -> c0 r) -> Constr -> c0 (CondBranch v c a) Source #

toConstr :: CondBranch v c a -> Constr Source #

dataTypeOf :: CondBranch v c a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c0 (t d)) -> Maybe (c0 (CondBranch v c a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c0 (t d e)) -> Maybe (c0 (CondBranch v c a)) Source #

gmapT :: (forall b. Data b => b -> b) -> CondBranch v c a -> CondBranch v c a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CondBranch v c a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CondBranch v c a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CondBranch v c a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CondBranch v c a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CondBranch v c a -> m (CondBranch v c a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CondBranch v c a -> m (CondBranch v c a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CondBranch v c a -> m (CondBranch v c a) Source #

Generic (CondBranch v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Associated Types

type Rep (CondBranch v c a) :: Type -> Type Source #

Methods

from :: CondBranch v c a -> Rep (CondBranch v c a) x Source #

to :: Rep (CondBranch v c a) x -> CondBranch v c a Source #

(Show v, Show a, Show c) => Show (CondBranch v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

showsPrec :: Int -> CondBranch v c a -> ShowS Source #

show :: CondBranch v c a -> String Source #

showList :: [CondBranch v c a] -> ShowS Source #

(Binary v, Binary c, Binary a) => Binary (CondBranch v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

put :: CondBranch v c a -> Put Source #

get :: Get (CondBranch v c a) Source #

putList :: [CondBranch v c a] -> Put Source #

(NFData v, NFData c, NFData a) => NFData (CondBranch v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

rnf :: CondBranch v c a -> () Source #

(Eq v, Eq a, Eq c) => Eq (CondBranch v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

Methods

(==) :: CondBranch v c a -> CondBranch v c a -> Bool #

(/=) :: CondBranch v c a -> CondBranch v c a -> Bool #

type Rep (CondBranch v c a) Source # 
Instance details

Defined in Distribution.Types.CondTree

type Rep (CondBranch v c a) = D1 ('MetaData "CondBranch" "Distribution.Types.CondTree" "Cabal-3.4.1.0" 'False) (C1 ('MetaCons "CondBranch" 'PrefixI 'True) (S1 ('MetaSel ('Just "condBranchCondition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Condition v)) :*: (S1 ('MetaSel ('Just "condBranchIfTrue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (CondTree v c a)) :*: S1 ('MetaSel ('Just "condBranchIfFalse") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (CondTree v c a))))))

condIfThenElse :: Condition v -> CondTree v c a -> CondTree v c a -> CondBranch v c a Source #

mapCondTree :: (a -> b) -> (c -> d) -> (Condition v -> Condition w) -> CondTree v c a -> CondTree w d b Source #

mapTreeConstrs :: (c -> d) -> CondTree v c a -> CondTree v d a Source #

mapTreeConds :: (Condition v -> Condition w) -> CondTree v c a -> CondTree w c a Source #

mapTreeData :: (a -> b) -> CondTree v c a -> CondTree v c b Source #

traverseCondTreeV :: Traversal (CondTree v c a) (CondTree w c a) v w Source #

@Traversal@ for the variables

traverseCondBranchV :: Traversal (CondBranch v c a) (CondBranch w c a) v w Source #

@Traversal@ for the variables

traverseCondTreeC :: Traversal (CondTree v c a) (CondTree v d a) c d Source #

@Traversal@ for the aggregated constraints

traverseCondBranchC :: Traversal (CondBranch v c a) (CondBranch v d a) c d Source #

@Traversal@ for the aggregated constraints

extractCondition :: Eq v => (a -> Bool) -> CondTree v c a -> Condition v Source #

Extract the condition matched by the given predicate from a cond tree.

We use this mainly for extracting buildable conditions (see the Note in Distribution.PackageDescription.Configuration), but the function is in fact more general.

simplifyCondTree :: (Semigroup a, Semigroup d) => (v -> Either v Bool) -> CondTree v d a -> (d, a) Source #

Flattens a CondTree using a partial flag assignment. When a condition cannot be evaluated, both branches are ignored.

ignoreConditions :: (Semigroup a, Semigroup c) => CondTree v c a -> (a, c) Source #

Flatten a CondTree. This will resolve the CondTree by taking all possible paths into account. Note that since branches represent exclusive choices this may not result in a "sane" result.