1-- | The 'Writer' as an effect.
12import Control.Monad.Catch
14import Effectful.Internal.Effect
15import Effectful.Internal.Env
16import Effectful.Internal.Monad
18-- | Provide access to a write only value of type @w@.
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
32writer :: (Writer w :> es, Monoid w) => (a, w) -> Eff es a
33writer (a, w) = stateEffect $ \(IdE (Writer w0)) -> (a, IdE (Writer (w0 <> w)))
35tell :: (Writer w :> es, Monoid w) => w -> Eff es ()
36tell w = stateEffect $ \(IdE (Writer w0)) -> ((), IdE (Writer (w0 <> w)))
39 :: forall w es a. (Writer w :> es, Monoid w)
42listen (Eff m) = unsafeEff $ \es -> mask $ \restore -> do
43 w0 <- unsafeStateEnv (\(IdE (Writer w)) -> (w, IdE (Writer mempty))) es
44 -- If an exception is thrown, restore e0 and keep parts of e1.
45 a <- restore (m es) `onException`
46 unsafeModifyEnv (\(IdE (Writer w)) -> IdE (Writer (w0 <> w))) es
47 w1 <- unsafeStateEnv (\(IdE (Writer w)) -> (w, IdE (Writer (w0 <> w)))) es
51 :: (Writer w :> es, Monoid w)
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