@@ -358,20 +358,24 @@ x `usingIO` strat = runEvalIO (strat x)
358
358
withStrategyIO :: Strategy a -> a -> IO a
359
359
withStrategyIO = flip usingIO
360
360
361
- -- | Compose two strategies sequentially.
362
- -- This is the analogue to function composition on strategies.
361
+ -- | Compose two strategies.
363
362
--
364
- -- For any strategies @strat1@, @strat2@, and @strat3@,
363
+ -- > strat2 `dot` strat1 == strat2 . withStrategy strat1
364
+ --
365
+ -- 'dot' is associative:
365
366
--
366
367
-- > (strat1 `dot` strat2) `dot` strat3 == strat1 `dot` (strat2 `dot` strat3)
367
- -- > strat1 `dot` strat1 = strat1
368
- -- > strat1 `dot` r0 == strat1
369
368
--
370
- -- > strat2 `dot` strat1 == strat2 . withStrategy strat1
369
+ -- 'r0' and 'rseq' are one-sided identities of 'dot':
371
370
--
371
+ -- > strat `dot` r0 == strat
372
+ -- > strat `dot` rseq == strat
373
+ {-# DEPRECATED dot "'dot' is an unintuitive composition operator. Use 'Control.Monad.<=<` instead." #-}
372
374
dot :: Strategy a -> Strategy a -> Strategy a
373
375
strat2 `dot` strat1 = strat2 . runEval . strat1
374
376
377
+ -- Note [dot proofs]
378
+ -- ~~~~~~~~~~~~~~~~~
375
379
-- Proof of strat2 `dot` strat1 == strat2 . withStrategy strat1
376
380
--
377
381
-- strat2 . withStrategy strat1
@@ -380,17 +384,14 @@ strat2 `dot` strat1 = strat2 . runEval . strat1
380
384
-- == \x -> strat2 (runEval (strat1 x))
381
385
-- == \x -> (strat2 . runEval . strat1) x
382
386
-- == strat2 `dot` strat1
383
-
384
- -- One might be tempted to think that 'dot' is equivalent to '(<=<)',
385
- -- the right-to-left Kleisli composition in the Eval monad, because
386
- -- '(<=<)' can take the type @Strategy a -> Strategy a -> Strategy a@
387
- -- and intuitively does what 'dot' does: First apply the strategy to the
388
- -- right then the one to the left. However, there is a subtle difference
389
- -- in strictness, witnessed by the following example:
390
387
--
391
- -- > (r0 `dot` rseq) undefined == Done undefined
392
- -- > (r0 <=< rseq) undefined == undefined
388
+ -- Proof of associativity
393
389
--
390
+ -- (strat1 `dot` strat2) `dot` strat3
391
+ -- == (strat1 . runEval . strat2) . runEval . strat3
392
+ -- == strat1 . runEval . strat2 . runEval . strat3
393
+ -- == strat1 . runEval . (strat2 . runEval . strat3)
394
+ -- == strat1 `dot` (strat2 `dot` strat3)
394
395
395
396
-- | Inject a sequential strategy (i.e., coerce a sequential strategy
396
397
-- to a general strategy).
0 commit comments