Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
13f359ca
Commit
13f359ca
authored
Jan 04, 2017
by
Edward Z. Yang
Committed by
Edward Z. Yang
Jan 06, 2017
Browse files
Documentation for CondTree and CondBranch.
Signed-off-by:
Edward Z. Yang
<
ezyang@cs.stanford.edu
>
parent
4856dbb1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Cabal/Distribution/Types/CondTree.hs
View file @
13f359ca
...
...
@@ -23,6 +23,31 @@ import Distribution.Compat.Prelude
import
Distribution.Types.Condition
-- | 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 'Monoid's.
--
-- 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.)
--
data
CondTree
v
c
a
=
CondNode
{
condTreeData
::
a
,
condTreeConstraints
::
c
...
...
@@ -32,6 +57,10 @@ data CondTree v c a = CondNode
instance
(
Binary
v
,
Binary
c
,
Binary
a
)
=>
Binary
(
CondTree
v
c
a
)
-- | A 'CondBranch' represents a conditional branch, e.g., @if
-- flag(foo)@ on some syntax @a@. It also has an optional false
-- branch.
--
data
CondBranch
v
c
a
=
CondBranch
{
condBranchCondition
::
Condition
v
,
condBranchIfTrue
::
CondTree
v
c
a
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment