Skip to content

Commit 4d3dd1a

Browse files
committed
#803, clarify the docs that Action goes in parallel
1 parent 99c5a7a commit 4d3dd1a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Development/Shake/Internal/Core/Action.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,9 @@ unsafeExtraThread act = do
477477

478478

479479
-- | Execute a list of actions in parallel. In most cases 'need' will be more appropriate to benefit from parallelism.
480+
-- If the two types of 'Action' are different dependencies which ultimately boil down to 'apply',
481+
-- using 'Applicative' operations will still ensure the dependencies occur in parallel.
482+
-- The main use of this function is to run work that happens in an 'Action' in parallel.
480483
parallel :: [Action a] -> Action [a]
481484
-- Note: There is no parallel_ unlike sequence_ because there is no stack benefit to doing so
482485
parallel [] = pure []

src/Development/Shake/Internal/Core/Types.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ import Prelude
5858
-- | The 'Action' monad, use 'liftIO' to raise 'IO' actions into it, and 'Development.Shake.need' to execute files.
5959
-- Action values are used by 'addUserRule' and 'action'. The 'Action' monad tracks the dependencies of a rule.
6060
-- To raise an exception call 'error', 'fail' or @'liftIO' . 'throwIO'@.
61+
--
62+
-- The 'Action' type is both a 'Monad' and 'Applicative'. Anything that is depended upon applicatively
63+
-- will have its dependencies run in parallel. For example @'need' [\"a\"] *> 'need [\"b\"]@ is equivalent
64+
-- to @'need' [\"a\", \"b\"]@.
6165
newtype Action a = Action {fromAction :: RAW ([String],[Key]) [Value] Global Local a}
6266
deriving (Functor, Applicative, Monad, MonadIO, Typeable, Semigroup, Monoid, MonadFail)
6367

0 commit comments

Comments
 (0)