Commit 8987ce06 authored by Joachim Breitner's avatar Joachim Breitner

Typos in Note

parent 378091c9
......@@ -175,8 +175,8 @@ foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m ()
foldM_ f a xs = foldlM f a xs >> return ()
Note [Worker/wrapper transform on replicateM/replicateM_
Note [Worker/wrapper transform on replicateM/replicateM_]
The implementations of replicateM and replicateM_ both leverage the
worker/wrapper transform. The simpler implementation of replicateM_, as an
......@@ -185,17 +185,14 @@ example, would be:
replicateM_ 0 _ = pure ()
replicateM_ n f = f *> replicateM_ (n - 1) f
However, the self-recrusive nature of this implementation inhibits inlining,
However, the self-recursive nature of this implementation inhibits inlining,
which means we never get to specialise to the action (`f` in the code above).
By contrast, the implementation below with a local loop makes it possible to
inline the entire definition (as hapens for foldr, for example) thereby
inline the entire definition (as happens for foldr, for example) thereby
specialising for the particular action.
For further information, see this Trac comment, which includes side-by-side
-- | @'replicateM' n act@ performs the action @n@ times,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment