| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Distribution.Types.CondTree
Synopsis
- data CondTree v a = CondNode {
- condTreeData :: a
- condTreeComponents :: [CondBranch v a]
- data CondBranch v a = CondBranch {
- condBranchCondition :: Condition v
- condBranchIfTrue :: CondTree v a
- condBranchIfFalse :: Maybe (CondTree v a)
- condIfThen :: Condition v -> CondTree v a -> CondBranch v a
- condIfThenElse :: Condition v -> CondTree v a -> CondTree v a -> CondBranch v a
- foldCondTree :: b -> (a -> b) -> (b -> b -> b) -> (b -> b -> b) -> CondTree v a -> b
- mapCondTree :: (a -> b) -> (Condition v -> Condition w) -> CondTree v a -> CondTree w b
- mapTreeConds :: (Condition v -> Condition w) -> CondTree v a -> CondTree w a
- mapTreeData :: (a -> b) -> CondTree v a -> CondTree v b
- traverseCondTreeA :: forall v a b f. Applicative f => LensLike f (CondTree v a) (CondTree v b) a b
- traverseCondTreeV :: forall v a w f. Applicative f => LensLike f (CondTree v a) (CondTree w a) v w
- traverseCondBranchA :: forall v a b f. Applicative f => LensLike f (CondBranch v a) (CondBranch v b) a b
- traverseCondBranchV :: forall v a w f. Applicative f => LensLike f (CondBranch v a) (CondBranch w a) v w
- extractCondition :: Eq v => (a -> Bool) -> CondTree v a -> Condition v
- simplifyCondTree :: Semigroup a => (v -> Either v Bool) -> CondTree v a -> a
- simplifyCondBranch :: Semigroup a => (v -> Either v Bool) -> CondBranch v a -> Maybe a
- ignoreConditions :: Semigroup a => CondTree v a -> a
Documentation
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 . Here, CondTree ConfVar
[Dependency] BuildInfocondTreeData 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 | |
Fields
| |
Instances
| Functor (CondTree v) Source # | |||||
| Foldable (CondTree v) Source # | |||||
Defined in Distribution.Types.CondTree Methods fold :: Monoid m => CondTree v m -> m Source # foldMap :: Monoid m => (a -> m) -> CondTree v a -> m Source # foldMap' :: Monoid m => (a -> m) -> CondTree v a -> m Source # foldr :: (a -> b -> b) -> b -> CondTree v a -> b Source # foldr' :: (a -> b -> b) -> b -> CondTree v a -> b Source # foldl :: (b -> a -> b) -> b -> CondTree v a -> b Source # foldl' :: (b -> a -> b) -> b -> CondTree v a -> b Source # foldr1 :: (a -> a -> a) -> CondTree v a -> a Source # foldl1 :: (a -> a -> a) -> CondTree v a -> a Source # toList :: CondTree v a -> [a] Source # null :: CondTree v a -> Bool Source # length :: CondTree v a -> Int Source # elem :: Eq a => a -> CondTree v a -> Bool Source # maximum :: Ord a => CondTree v a -> a Source # minimum :: Ord a => CondTree v a -> a Source # | |||||
| Traversable (CondTree v) Source # | |||||
Defined in Distribution.Types.CondTree Methods traverse :: Applicative f => (a -> f b) -> CondTree v a -> f (CondTree v b) Source # sequenceA :: Applicative f => CondTree v (f a) -> f (CondTree v a) Source # mapM :: Monad m => (a -> m b) -> CondTree v a -> m (CondTree v b) Source # sequence :: Monad m => CondTree v (m a) -> m (CondTree v a) Source # | |||||
| (Structured v, Structured a) => Structured (CondTree v a) Source # | |||||
Defined in Distribution.Types.CondTree | |||||
| (Binary v, Binary a) => Binary (CondTree v a) Source # | |||||
| (NFData v, NFData a) => NFData (CondTree v a) Source # | |||||
Defined in Distribution.Types.CondTree | |||||
| Monoid a => Monoid (CondTree v a) Source # | |||||
| Semigroup a => Semigroup (CondTree v a) Source # | |||||
| (Eq a, Eq v) => Eq (CondTree v a) Source # | |||||
| (Data v, Data a) => Data (CondTree v a) Source # | |||||
Defined in Distribution.Types.CondTree Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CondTree v a -> c (CondTree v a) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (CondTree v a) Source # toConstr :: CondTree v a -> Constr Source # dataTypeOf :: CondTree v a -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (CondTree v a)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (CondTree v a)) Source # gmapT :: (forall b. Data b => b -> b) -> CondTree v a -> CondTree v a Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CondTree v a -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CondTree v a -> r Source # gmapQ :: (forall d. Data d => d -> u) -> CondTree v a -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> CondTree v a -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a) Source # | |||||
| Generic (CondTree v a) Source # | |||||
Defined in Distribution.Types.CondTree Associated Types
| |||||
| (Show a, Show v) => Show (CondTree v a) Source # | |||||
| type Rep (CondTree v a) Source # | |||||
Defined in Distribution.Types.CondTree type Rep (CondTree v a) = D1 ('MetaData "CondTree" "Distribution.Types.CondTree" "Cabal-syntax-3.18.1.0-53ed" 'False) (C1 ('MetaCons "CondNode" 'PrefixI 'True) (S1 ('MetaSel ('Just "condTreeData") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "condTreeComponents") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [CondBranch v a]))) | |||||
data CondBranch v a Source #
A CondBranch represents a conditional branch, e.g., if
flag(foo) on some syntax a. It also has an optional false
branch.
Constructors
| CondBranch | |
Fields
| |
Instances
condIfThen :: Condition v -> CondTree v a -> CondBranch v a Source #
condIfThenElse :: Condition v -> CondTree v a -> CondTree v a -> CondBranch v a Source #
foldCondTree :: b -> (a -> b) -> (b -> b -> b) -> (b -> b -> b) -> CondTree v a -> b Source #
Flatten a CondTree. This will traverse the CondTree by taking all possible paths into account, but merging inclusive when two paths may co-exist, and exclusively when the paths are an if/else
mapTreeData :: (a -> b) -> CondTree v a -> CondTree v b Source #
traverseCondTreeA :: forall v a b f. Applicative f => LensLike f (CondTree v a) (CondTree v b) a b Source #
@Traversal@ for the data
traverseCondTreeV :: forall v a w f. Applicative f => LensLike f (CondTree v a) (CondTree w a) v w Source #
@Traversal@ for the variables
traverseCondBranchA :: forall v a b f. Applicative f => LensLike f (CondBranch v a) (CondBranch v b) a b Source #
@Traversal@ for the data
traverseCondBranchV :: forall v a w f. Applicative f => LensLike f (CondBranch v a) (CondBranch w a) v w Source #
@Traversal@ for the variables
extractCondition :: Eq v => (a -> Bool) -> CondTree v 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 => (v -> Either v Bool) -> CondTree v a -> a Source #
Flattens a CondTree using a partial flag assignment. When a condition cannot be evaluated, both branches are ignored.
simplifyCondBranch :: Semigroup a => (v -> Either v Bool) -> CondBranch v a -> Maybe a Source #
Realizes a CondBranch using partial flag assignment. When a condition
cannot be evaluated, returns Nothing.
ignoreConditions :: Semigroup a => CondTree v a -> a 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.