on master help sign in
Add description of listens to Effectful.Writer.Shared
commitdadd56f52dd8889a30cd2f2bc4ec527e805c666a authorAndrzej Rybczak <andrzej@rybczak.net> dateSun 19 Dec 2021, 03:07 (5 years ago) parent3294d3b
1 file changed+5
effectful-core/src/Effectful/Writer/Shared.hs+5
effectful-core/src/Effectful/Writer/Shared.hs+5
@@ -82,6 +82,11 @@ listen m = unsafeEff $ \es -> do
8282 modifyMVar_ v0 $ \w0 -> let w = w0 <> w1 in w `seq` pure w
8383 pure w1
8484
85+-- | Execute an action and append its output to the overall output of the
86+-- 'Writer', then return the final value along with a function of the recorded
87+-- output.
88+--
89+-- @'listens' f m ≡ 'Data.Bifunctor.second' f '<$>' 'listen' m@
8590listens :: (Writer w :> es, Monoid w) => (w -> b) -> Eff es a -> Eff es (a, b)
8691listens f m = do
8792 (a, w) <- listen m