From 9a57483a647f438c24d0b96c4ab3f1149f8e9c48 Mon Sep 17 00:00:00 2001 From: David Feuer Date: Mon, 4 Jun 2018 09:46:38 -0400 Subject: [PATCH 1/2] Fix dot documentation I goofed up and made the ``strat1 `dot` strat1 = strat1`` law too strong. Fix that. Also, add laws for ``rpar `dot` rseq`` and ``rseq `dot` rpar``. --- Control/Parallel/Strategies.hs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Control/Parallel/Strategies.hs b/Control/Parallel/Strategies.hs index cde91a5..ed565cc 100644 --- a/Control/Parallel/Strategies.hs +++ b/Control/Parallel/Strategies.hs @@ -296,14 +296,25 @@ withStrategy = flip using -- | Compose two strategies sequentially. -- This is the analogue to function composition on strategies. -- --- For any strategies @strat1@, @strat2@, and @strat3@, --- -- > (strat1 `dot` strat2) `dot` strat3 == strat1 `dot` (strat2 `dot` strat3) --- > strat1 `dot` strat1 = strat1 --- > strat1 `dot` r0 == strat1 +-- > strat `dot` r0 == strat +-- > rpar `dot` rseq == rpar +-- > rseq `dot` rpar == rseq +-- > r0 `dot` rpar == r0 +-- > r0 `dot` rseq == r0 -- -- > strat2 `dot` strat1 == strat2 . withStrategy strat1 -- +-- Furthermore, if @strat@ only forces and sparks computations (that is, it +-- doesn't actually change any values), then +-- +-- > strat `dot` strat == strat +-- +-- In particular, +-- +-- > rpar `dot` rpar == rpar +-- > rseq `dot` rseq == rseq +-- dot :: Strategy a -> Strategy a -> Strategy a strat2 `dot` strat1 = strat2 . runEval . strat1 From 1e27bea493803cd55e13b140aa9a1815fd218ac2 Mon Sep 17 00:00:00 2001 From: David Feuer Date: Tue, 5 Jun 2018 10:28:20 -0400 Subject: [PATCH 2/2] Simplify and extend --- Control/Parallel/Strategies.hs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Control/Parallel/Strategies.hs b/Control/Parallel/Strategies.hs index ed565cc..914fdba 100644 --- a/Control/Parallel/Strategies.hs +++ b/Control/Parallel/Strategies.hs @@ -296,24 +296,22 @@ withStrategy = flip using -- | Compose two strategies sequentially. -- This is the analogue to function composition on strategies. -- --- > (strat1 `dot` strat2) `dot` strat3 == strat1 `dot` (strat2 `dot` strat3) --- > strat `dot` r0 == strat --- > rpar `dot` rseq == rpar --- > rseq `dot` rpar == rseq --- > r0 `dot` rpar == r0 --- > r0 `dot` rseq == r0 --- -- > strat2 `dot` strat1 == strat2 . withStrategy strat1 -- --- Furthermore, if @strat@ only forces and sparks computations (that is, it --- doesn't actually change any values), then +-- 'dot' is associative: -- --- > strat `dot` strat == strat +-- > (strat1 `dot` strat2) `dot` strat3 == strat1 `dot` (strat2 `dot` strat3) -- --- In particular, +-- 'r0', 'rseq', and 'rpar' are all one-sided identities of 'dot': -- --- > rpar `dot` rpar == rpar --- > rseq `dot` rseq == rseq +-- > strat `dot` r0 == strat +-- > strat `dot` rseq == strat +-- > strat `dot` rpar == strat +-- +-- Furthermore, since strategies should only force and sparks computations +-- (that is, they don't actually change any values), +-- +-- > strat `dot` strat == strat -- dot :: Strategy a -> Strategy a -> Strategy a strat2 `dot` strat1 = strat2 . runEval . strat1