1-- | The 'Writer' effect.
11import Control.Monad.Catch
13import Effectful.Internal.Effect
14import Effectful.Internal.Env
15import Effectful.Internal.Monad
17-- | Provide access to a strict (WHNF), thread local, write only value of type
19newtype Writer w :: Effect where
20 Writer :: w -> Writer w m r
22runWriter :: Monoid w => Eff (Writer w : es) a -> Eff es (a, w)
24 (a, IdE (Writer w)) <- runEffect (IdE (Writer mempty)) m
27execWriter :: Monoid w => Eff (Writer w : es) a -> Eff es w
29 IdE (Writer w) <- execEffect (IdE (Writer mempty)) m
32tell :: (Writer w :> es, Monoid w) => w -> Eff es ()
33tell w = stateEffect $ \(IdE (Writer w0)) -> ((), IdE (Writer (w0 <> w)))
35listen :: (Writer w :> es, Monoid w) => Eff es a -> Eff es (a, w)
36listen m = unsafeEff $ \es -> mask $ \restore -> do
37 w0 <- unsafeStateEnv (\(IdE (Writer w)) -> (w, IdE (Writer mempty))) es
38 a <- restore (unEff m es) `onException` merge es w0
42 -- If an exception is thrown, restore w0 and keep parts of w1.
43 unsafeStateEnv (\(IdE (Writer w1)) -> (w1, IdE (Writer (w0 <> w1)))) es
45listens :: (Writer w :> es, Monoid w) => (w -> b) -> Eff es a -> Eff es (a, b)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list