Skip to content

Commit bb58c64

Browse files
committed
Add Haddock documentation and reformat
1 parent 437fa32 commit bb58c64

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/Control/Concurrent/Execute.hs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,45 +28,53 @@ instance Exception ExecuteException where
2828
"Inconsistent dependencies were discovered while executing your build \
2929
\plan."
3030

31+
-- | Type representing types of Stack build actions.
3132
data ActionType
3233
= ATBuild
3334
-- ^ Action for building a package's library and executables. If
34-
-- 'taskAllInOne' is 'True', then this will also build benchmarks
35-
-- and tests. It is 'False' when then library's benchmarks or
36-
-- test-suites have cyclic dependencies.
35+
-- 'taskAllInOne' is 'True', then this will also build benchmarks and tests.
36+
-- It is 'False' when the library's benchmarks or test-suites have cyclic
37+
-- dependencies.
3738
| ATBuildFinal
38-
-- ^ Task for building the package's benchmarks and test-suites.
39-
-- Requires that the library was already built.
39+
-- ^ Task for building the package's benchmarks and test-suites. Requires
40+
-- that the library was already built.
4041
| ATRunTests
4142
-- ^ Task for running the package's test-suites.
4243
| ATRunBenchmarks
4344
-- ^ Task for running the package's benchmarks.
4445
deriving (Show, Eq, Ord)
4546

47+
-- | Types representing the unique ids of Stack build actions.
4648
data ActionId
4749
= ActionId !PackageIdentifier !ActionType
4850
deriving (Eq, Ord, Show)
4951

50-
data Action
51-
= Action
52+
-- | Type representing Stack build actions.
53+
data Action = Action
5254
{ actionId :: !ActionId
55+
-- ^ The action's unique id.
5356
, actionDeps :: !(Set ActionId)
57+
-- ^ Actions on which this action depends.
5458
, actionDo :: !(ActionContext -> IO ())
59+
-- ^ The action's 'IO' action, given a context.
5560
, actionConcurrency :: !Concurrency
61+
-- ^ Whether this action may be run concurrently with others.
5662
}
5763

64+
-- | Type representing permissions for actions to be run concurrently with
65+
-- others.
5866
data Concurrency
5967
= ConcurrencyAllowed
6068
| ConcurrencyDisallowed
6169
deriving Eq
6270

6371
data ActionContext = ActionContext
6472
{ acRemaining :: !(Set ActionId)
65-
-- ^ Does not include the current action
73+
-- ^ Does not include the current action.
6674
, acDownstream :: [Action]
67-
-- ^ Actions which depend on the current action
75+
-- ^ Actions which depend on the current action.
6876
, acConcurrency :: !Concurrency
69-
-- ^ Whether this action may be run concurrently with others
77+
-- ^ Whether this action may be run concurrently with others.
7078
}
7179

7280
data ExecuteState = ExecuteState
@@ -77,11 +85,12 @@ data ExecuteState = ExecuteState
7785
, esKeepGoing :: Bool
7886
}
7987

80-
runActions :: Int -- ^ threads
81-
-> Bool -- ^ keep going after one task has failed
82-
-> [Action]
83-
-> (TVar Int -> TVar (Set ActionId) -> IO ()) -- ^ progress updated
84-
-> IO [SomeException]
88+
runActions ::
89+
Int -- ^ threads
90+
-> Bool -- ^ keep going after one task has failed
91+
-> [Action]
92+
-> (TVar Int -> TVar (Set ActionId) -> IO ()) -- ^ progress updated
93+
-> IO [SomeException]
8594
runActions threads keepGoing actions withProgress = do
8695
es <- ExecuteState
8796
<$> newTVarIO (sortActions actions) -- esActions
@@ -161,5 +170,7 @@ runActions' ExecuteState {..} = loop
161170
in modifyTVar esActions $ map dropDep
162171
restore loop
163172

173+
-- | Filter a list of actions to include only those that depend on the given
174+
-- action.
164175
downstreamActions :: ActionId -> [Action] -> [Action]
165176
downstreamActions aid = filter (\a -> aid `Set.member` actionDeps a)

0 commit comments

Comments
 (0)