2-- | The 'Writer' as an effect.
13import Control.Monad.Catch
15import Effectful.Internal.Effect
16import Effectful.Internal.Env
17import Effectful.Internal.Monad
19-- | Provide access to a write only value of type @w@.
20newtype Writer w :: Effect where
21 Writer :: w -> Writer w m r
23runWriter :: Monoid w => Eff (Writer w : es) a -> Eff es (a, w)
25 (a, IdE (Writer w)) <- runEffect (IdE (Writer mempty)) m
28execWriter :: Monoid w => Eff (Writer w : es) a -> Eff es w
30 IdE (Writer w) <- execEffect (IdE (Writer mempty)) m
33writer :: (Writer w :> es, Monoid w) => (a, w) -> Eff es a
34writer (a, w) = stateEffect $ \(IdE (Writer w0)) -> (a, IdE (Writer (w0 `mappend` w)))
36tell :: (Writer w :> es, Monoid w) => w -> Eff es ()
37tell w = stateEffect $ \(IdE (Writer w0)) -> ((), IdE (Writer (w0 `mappend` w)))
40 :: forall w es a. (Writer w :> es, Monoid w)
43listen (Eff m) = unsafeEff $ \es -> mask $ \restore -> do
44#if __GLASGOW_HASKELL__ >= 900
45 error $ "'listen' temporarily doesn't compile with released GHC 9.* versions"
46 ++ " due to a GHC bug. If you want to use 'listen', please use GHC 8.*"
48 w0 <- unsafeStateEnv (\(IdE (Writer w)) -> (w, IdE (Writer mempty))) es
49 -- If an exception is thrown, restore e0 and keep parts of e1.
50 a <- restore (m es) `onException`
51 unsafeModifyEnv (\(IdE (Writer w)) -> IdE (Writer (w0 `mappend` w))) es
52 w1 <- unsafeStateEnv (\(IdE (Writer w)) -> (w, IdE (Writer (w0 `mappend` w)))) es
57 :: (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