Skip to content

Commit 82b72a7

Browse files
authored
Document list strategies that evaluate the spine (#78)
1 parent 353b64f commit 82b72a7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Control/Parallel/Strategies.hs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,10 @@ parTraversable strat = evalTraversable (rparWith strat)
540540
-- Strategies for lists
541541

542542
-- | Evaluate each element of a list according to the given strategy.
543-
-- Equivalent to 'evalTraversable' at the list type.
543+
-- Equivalent to 'evalTraversable' at the list type.
544+
--
545+
-- __Warning:__ This strategy evaluates the spine of the list
546+
-- and thus does not work on infinite lists.
544547
evalList :: Strategy a -> Strategy [a]
545548
evalList = evalTraversable
546549
-- Alternative explicitly recursive definition:
@@ -550,14 +553,17 @@ evalList = evalTraversable
550553
-- return (x':xs')
551554

552555
-- | Evaluate each element of a list in parallel according to given strategy.
553-
-- Equivalent to 'parTraversable' at the list type.
556+
-- Equivalent to 'parTraversable' at the list type.
557+
--
558+
-- __Warning:__ This strategy evaluates the spine of the list
559+
-- and thus does not work on infinite lists.
554560
parList :: Strategy a -> Strategy [a]
555561
parList = parTraversable
556562
-- Alternative definition via evalList:
557563
-- parList strat = evalList (rparWith strat)
558564

559565
-- | @'evaListSplitAt' n stratPref stratSuff@ evaluates the prefix
560-
-- (of length @n@) of a list according to @stratPref@ and its the suffix
566+
-- (of length @n@) of a list according to @stratPref@ and the suffix
561567
-- according to @stratSuff@.
562568
evalListSplitAt :: Int -> Strategy [a] -> Strategy [a] -> Strategy [a]
563569
evalListSplitAt n stratPref stratSuff xs
@@ -598,6 +604,9 @@ parListNth n strat = evalListNth n (rparWith strat)
598604
--
599605
-- This function may be replaced by a more
600606
-- generic clustering infrastructure in the future.
607+
--
608+
-- __Warning:__ This strategy evaluates the spine of the list
609+
-- and thus does not work on infinite lists.
601610
parListChunk :: Int -> Strategy a -> Strategy [a]
602611
parListChunk n strat
603612
| n <= 1 = parList strat
@@ -630,6 +639,8 @@ evalChunk strat = \end ->
630639
--
631640
-- > parMap strat f = withStrategy (parList strat) . map f
632641
--
642+
-- __Warning:__ This function evaluates the spine of the list
643+
-- and thus does not work on infinite lists.
633644
parMap :: Strategy b -> (a -> b) -> [a] -> [b]
634645
parMap strat f = (`using` parList strat) . map f
635646

0 commit comments

Comments
 (0)