Safe Haskell  None 

Language  Haskell2010 
 data CondTree v c a = CondNode {
 condTreeData :: a
 condTreeConstraints :: c
 condTreeComponents :: [CondBranch v c a]
 data CondBranch v c a = CondBranch {
 condBranchCondition :: Condition v
 condBranchIfTrue :: CondTree v c a
 condBranchIfFalse :: Maybe (CondTree v c a)
 condIfThen :: Condition v > CondTree v c a > CondBranch v c a
 condIfThenElse :: Condition v > CondTree v c a > CondTree v c a > CondBranch v c a
 mapCondTree :: (a > b) > (c > d) > (Condition v > Condition w) > CondTree v c a > CondTree w d b
 mapTreeConstrs :: (c > d) > CondTree v c a > CondTree v d a
 mapTreeConds :: (Condition v > Condition w) > CondTree v c a > CondTree w c a
 mapTreeData :: (a > b) > CondTree v c a > CondTree v c b
 extractCondition :: Eq v => (a > Bool) > CondTree v c a > Condition v
 simplifyCondTree :: (Monoid a, Monoid d) => (v > Either v Bool) > CondTree v d a > (d, a)
 ignoreConditions :: (Monoid a, Monoid c) => CondTree v c a > (a, c)
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 subelements which may be enabled subject
to some condition. Both a
and c
are usually Monoid
s.
To be more concrete, consider the following fragment of a Cabal
file:
builddepends: base >= 4.0 if flag(extra) builddepends: base >= 4.2
One way to represent this is to have
. Here, CondTree
ConfVar
[Dependency
] BuildInfo
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 precomputes the dependencies.)
CondNode  

Functor (CondTree v c) Source #  
Foldable (CondTree v c) Source #  
Traversable (CondTree v c) Source #  
(Eq v, Eq c, Eq a) => Eq (CondTree v c a) Source #  
(Data a, Data c, Data v) => Data (CondTree v c a) Source #  
(Show v, Show c, Show a) => Show (CondTree v c a) Source #  
Generic (CondTree v c a) Source #  
(Binary v, Binary c, Binary a) => Binary (CondTree v c a) Source #  
type Rep (CondTree v c a) Source #  
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.
CondBranch  

Functor (CondBranch v c) Source #  
Foldable (CondBranch v c) Source #  
Traversable (CondBranch v c) Source #  
(Eq a, Eq c, Eq v) => Eq (CondBranch v c a) Source #  
(Data a, Data c, Data v) => Data (CondBranch v c a) Source #  
(Show a, Show c, Show v) => Show (CondBranch v c a) Source #  
Generic (CondBranch v c a) Source #  
(Binary v, Binary c, Binary a) => Binary (CondBranch v c a) Source #  
type Rep (CondBranch v c a) Source #  
condIfThen :: Condition v > CondTree v c a > CondBranch v c a Source #
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 #
mapTreeData :: (a > b) > CondTree v c a > CondTree v c b Source #
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 above), but the function is in fact more general.