mirror of
https://github.com/sayo-hs/heftia.git
synced 2024-11-23 02:42:06 +03:00
Reexport 'Data.Effect.*' from the interpreters module 'Control.Monad.Hefty.*'.
This commit is contained in:
parent
7dcb2dd999
commit
e06aa3cbec
@ -21,3 +21,11 @@
|
||||
* Support for the core package update to version 0.4.
|
||||
* Dropped support for GHC 9.2.8, now supporting GHC 9.4.1 and later.
|
||||
* Added benchmarks and tests.
|
||||
|
||||
## 0.5.0.0 -- 2024-10-12
|
||||
|
||||
* **Breaking changes**
|
||||
* Renamed `Control.Monad.Hefty.Provider.provide`/`provide_` -> `scope`/`scoped_`
|
||||
* Renamed `Control.Monad.Hefty.Writer.listen` -> `intercept`
|
||||
|
||||
* Reexported `Data.Effect.*` from the interpreters module `Control.Monad.Hefty.*`.
|
||||
|
@ -17,7 +17,7 @@ import Control.Monad.Hefty (
|
||||
type (<|),
|
||||
type (~>),
|
||||
)
|
||||
import Control.Monad.Hefty.Provider (ProviderFix_, provide_, runProvider_)
|
||||
import Control.Monad.Hefty.Provider (ProviderFix_, runProvider_, scope_)
|
||||
|
||||
data FileSystemF a where
|
||||
ReadFS :: FilePath -> FileSystemF String
|
||||
@ -48,8 +48,8 @@ runDummyFSProvider =
|
||||
main :: IO ()
|
||||
main =
|
||||
runEff . runDummyFSProvider $
|
||||
provide_ @"fs1" "/fs1" \_ -> do
|
||||
provide_ @"fs2" "/fs2" \inBase -> do
|
||||
scope_ @"fs1" "/fs1" \_ -> do
|
||||
scope_ @"fs2" "/fs2" \inBase -> do
|
||||
inBase do
|
||||
s1 <- readFS' @"fs1" "/a/b/c"
|
||||
liftIO $ putStrLn $ "content: " <> show s1
|
||||
|
@ -13,8 +13,6 @@ import Control.Monad.Hefty.Except qualified as H
|
||||
import Control.Monad.Hefty.Reader qualified as H
|
||||
import Control.Monad.Identity qualified as M
|
||||
import Control.Monad.Reader qualified as M
|
||||
import Data.Effect.Except qualified as H
|
||||
import Data.Effect.Reader qualified as H
|
||||
import Effectful qualified as EL
|
||||
import Effectful.Error.Dynamic qualified as EL
|
||||
import Effectful.Reader.Dynamic qualified as EL
|
||||
|
@ -12,7 +12,6 @@ import Control.Monad.Hefty.Coroutine qualified as H
|
||||
import Control.Monad.Hefty.Reader qualified as H
|
||||
import Control.Mp.Eff qualified as Mp
|
||||
import Control.Mp.Util qualified as Mp
|
||||
import Data.Effect.Coroutine qualified as H
|
||||
import "eff" Control.Effect qualified as E
|
||||
|
||||
programFreer :: (FS.Member (FS.Yield Int Int) es) => Int -> FS.Eff es [Int]
|
||||
|
@ -17,7 +17,6 @@ import Control.Monad.Hefty.State qualified as H
|
||||
import Control.Monad.Identity qualified as M
|
||||
import Control.Monad.Reader qualified as M
|
||||
import Control.Monad.State.Strict qualified as M
|
||||
import Data.Effect.State qualified as H
|
||||
import Effectful qualified as EL
|
||||
import Effectful.Reader.Dynamic qualified as EL
|
||||
import Effectful.State.Dynamic qualified as EL
|
||||
|
@ -22,7 +22,6 @@ import Control.Monad.Logic qualified as M
|
||||
import Control.Monad.Reader qualified as M
|
||||
import Control.Mp.Eff qualified as Mp
|
||||
import Control.Mp.Util qualified as Mp
|
||||
import Data.Effect.NonDet qualified as H
|
||||
import "eff" Control.Effect qualified as EF
|
||||
|
||||
programFreer :: (FS.Member FS.NonDet es) => Int -> FS.Eff es (Int, Int, Int)
|
||||
|
@ -1,6 +1,6 @@
|
||||
cabal-version: 2.4
|
||||
name: heftia-effects
|
||||
version: 0.4.0.0
|
||||
version: 0.5.0.0
|
||||
|
||||
-- A short (one-line) description of the package.
|
||||
synopsis: higher-order effects done right
|
||||
|
@ -1,10 +1,12 @@
|
||||
-- SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
module Control.Monad.Hefty.Concurrent.Timer where
|
||||
module Control.Monad.Hefty.Concurrent.Timer (
|
||||
module Control.Monad.Hefty.Concurrent.Timer,
|
||||
module Data.Effect.Concurrent.Timer,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Concurrent.Thread.Delay qualified as Thread
|
||||
import Control.Monad.Hefty.Coroutine (runCoroutine)
|
||||
import Control.Monad.Hefty.State (evalState)
|
||||
import Control.Monad.Hefty (
|
||||
interpose,
|
||||
interpret,
|
||||
@ -17,7 +19,9 @@ import Control.Monad.Hefty (
|
||||
type (<|),
|
||||
type (~>),
|
||||
)
|
||||
import Data.Effect.Concurrent.Timer (CyclicTimer (Wait), Timer (..), clock, cyclicTimer)
|
||||
import Control.Monad.Hefty.Coroutine (runCoroutine)
|
||||
import Control.Monad.Hefty.State (evalState)
|
||||
import Data.Effect.Concurrent.Timer
|
||||
import Data.Effect.Coroutine (Status (Continue, Done))
|
||||
import Data.Effect.State (get, put)
|
||||
import Data.Time (DiffTime)
|
||||
|
@ -1,10 +1,14 @@
|
||||
-- SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
module Control.Monad.Hefty.Coroutine where
|
||||
module Control.Monad.Hefty.Coroutine (
|
||||
module Control.Monad.Hefty.Coroutine,
|
||||
module Data.Effect.Coroutine,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Monad.Hefty.Interpret (interpretBy)
|
||||
import Control.Monad.Hefty.Types (Eff)
|
||||
import Data.Effect.Coroutine (Status (Continue, Done), Yield (Yield))
|
||||
import Data.Effect.Coroutine
|
||||
|
||||
runCoroutine
|
||||
:: forall a b ans r
|
||||
|
@ -10,26 +10,27 @@ Portability : portable
|
||||
|
||||
Interpreters for the t'Data.Effect.Except.Throw' / t'Data.Effect.Except.Catch' effects.
|
||||
-}
|
||||
module Control.Monad.Hefty.Except where
|
||||
module Control.Monad.Hefty.Except (
|
||||
module Control.Monad.Hefty.Except,
|
||||
module Data.Effect.Except,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Exception (Exception)
|
||||
import Control.Monad.Hefty (
|
||||
Eff,
|
||||
Interpreter,
|
||||
bundleAllH,
|
||||
interposeWith,
|
||||
interpret,
|
||||
interpretBy,
|
||||
interpretH,
|
||||
nilH,
|
||||
(!!+),
|
||||
(&),
|
||||
type (<<|),
|
||||
type (<|),
|
||||
type (~>),
|
||||
type (~~>),
|
||||
)
|
||||
import Data.Effect.Except (Catch (Catch), Throw (Throw))
|
||||
import Data.Effect.Except
|
||||
import Data.Effect.Unlift (UnliftIO)
|
||||
import UnliftIO (throwIO)
|
||||
import UnliftIO qualified as IO
|
||||
@ -62,9 +63,3 @@ runCatchIO
|
||||
. (UnliftIO <<| eh, IO <| ef, Exception e)
|
||||
=> Eff (Catch e ': eh) ef ~> Eff eh ef
|
||||
runCatchIO = interpretH \(Catch action hdl) -> IO.catch action hdl
|
||||
|
||||
prog :: Eff '[Catch String, Catch Int] '[Throw String, Throw Int] ()
|
||||
prog = undefined
|
||||
|
||||
prog' :: Eff '[] [Throw String, Throw Int] ()
|
||||
prog' = interpretH (elabCatch @String !!+ elabCatch @Int !!+ nilH) . bundleAllH $ prog
|
||||
|
@ -8,10 +8,15 @@ License : MPL-2.0 (see the LICENSE file)
|
||||
Maintainer : ymdfield@outlook.jp
|
||||
Portability : portable
|
||||
-}
|
||||
module Control.Monad.Hefty.Fail where
|
||||
module Control.Monad.Hefty.Fail (
|
||||
module Control.Monad.Hefty.Fail,
|
||||
module Data.Effect.Fail,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Monad.Fail qualified as IO
|
||||
import Control.Monad.Hefty (Eff, interpret, liftIO, type (<|), type (~>))
|
||||
import Data.Effect.Fail (Fail (Fail))
|
||||
import Data.Effect.Fail
|
||||
|
||||
runFailIO :: (IO <| ef) => Eff eh (Fail ': ef) ~> Eff eh ef
|
||||
runFailIO = interpret \(Fail s) -> liftIO $ fail s
|
||||
runFailIO = interpret \(Fail s) -> liftIO $ IO.fail s
|
||||
|
@ -8,12 +8,15 @@ License : MPL-2.0 (see the LICENSE file)
|
||||
Maintainer : ymdfield@outlook.jp
|
||||
Portability : portable
|
||||
-}
|
||||
module Control.Monad.Hefty.Fresh where
|
||||
module Control.Monad.Hefty.Fresh (
|
||||
module Control.Monad.Hefty.Fresh,
|
||||
module Data.Effect.Fresh,
|
||||
) where
|
||||
|
||||
import Control.Arrow ((>>>))
|
||||
import Control.Monad.Hefty (Eff, interpret, raiseUnder, type (<|), type (~>))
|
||||
import Control.Monad.Hefty.State (runState)
|
||||
import Data.Effect.Fresh (Fresh (Fresh))
|
||||
import Data.Effect.Fresh
|
||||
import Data.Effect.State (State, get, modify)
|
||||
import Numeric.Natural (Natural)
|
||||
|
||||
|
@ -8,12 +8,16 @@ License : MPL-2.0 (see the LICENSE file)
|
||||
Maintainer : ymdfield@outlook.jp
|
||||
Portability : portable
|
||||
-}
|
||||
module Control.Monad.Hefty.Input where
|
||||
module Control.Monad.Hefty.Input (
|
||||
module Control.Monad.Hefty.Input,
|
||||
module Data.Effect.Input,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Arrow ((>>>))
|
||||
import Control.Monad.Hefty (Eff, interpret, raiseUnder, type (~>))
|
||||
import Control.Monad.Hefty.State (evalState)
|
||||
import Data.Effect.Input (Input (Input))
|
||||
import Data.Effect.Input
|
||||
import Data.Effect.State (gets, put)
|
||||
import Data.List (uncons)
|
||||
|
||||
|
@ -12,12 +12,16 @@ This module provides handlers for the t`KVStore` effect, comes
|
||||
from [@Polysemy.KVStore@](https://hackage.haskell.org/package/polysemy-kvstore-0.1.3.0/docs/Polysemy-KVStore.html)
|
||||
in the @polysemy-kvstore@ package.
|
||||
-}
|
||||
module Control.Monad.Hefty.KVStore where
|
||||
module Control.Monad.Hefty.KVStore (
|
||||
module Control.Monad.Hefty.KVStore,
|
||||
module Data.Effect.KVStore,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Arrow ((>>>))
|
||||
import Control.Monad.Hefty (Eff, interpret, raiseUnder, type (<|), type (~>))
|
||||
import Control.Monad.Hefty.State (runState)
|
||||
import Data.Effect.KVStore (KVStore (LookupKV, UpdateKV))
|
||||
import Data.Effect.KVStore
|
||||
import Data.Effect.State (State, get, modify)
|
||||
import Data.Functor ((<&>))
|
||||
import Data.Map (Map)
|
||||
|
@ -10,12 +10,17 @@ License : MPL-2.0 (see the LICENSE file)
|
||||
Maintainer : ymdfield@outlook.jp
|
||||
Portability : portable
|
||||
-}
|
||||
module Control.Monad.Hefty.NonDet where
|
||||
module Control.Monad.Hefty.NonDet (
|
||||
module Control.Monad.Hefty.NonDet,
|
||||
module Data.Effect.NonDet,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Applicative (Alternative ((<|>)), empty, (<|>))
|
||||
import Control.Applicative (Alternative ((<|>)), (<|>))
|
||||
#if ( __GLASGOW_HASKELL__ < 906 )
|
||||
import Control.Applicative (liftA2)
|
||||
#endif
|
||||
import Control.Applicative qualified as A
|
||||
import Control.Arrow ((>>>))
|
||||
import Control.Monad.Hefty (
|
||||
Eff,
|
||||
@ -28,7 +33,7 @@ import Control.Monad.Hefty (
|
||||
type (~>),
|
||||
)
|
||||
import Data.Bool (bool)
|
||||
import Data.Effect.NonDet (Choose (Choose), ChooseH (ChooseH), Empty (Empty), choose)
|
||||
import Data.Effect.NonDet
|
||||
|
||||
-- | 'NonDet' effects handler for alternative answer type.
|
||||
runNonDet
|
||||
@ -41,7 +46,7 @@ runNonDet =
|
||||
>>> interpretBy
|
||||
(pure . pure)
|
||||
( (\Choose k -> liftA2 (<|>) (k False) (k True))
|
||||
!+ (\Empty _ -> pure empty)
|
||||
!+ (\Empty _ -> pure A.empty)
|
||||
!+ nil
|
||||
)
|
||||
|
||||
|
@ -8,13 +8,17 @@ License : MPL-2.0 (see the LICENSE file)
|
||||
Maintainer : ymdfield@outlook.jp
|
||||
Portability : portable
|
||||
-}
|
||||
module Control.Monad.Hefty.Output where
|
||||
module Control.Monad.Hefty.Output (
|
||||
module Control.Monad.Hefty.Output,
|
||||
module Data.Effect.Output,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Arrow ((>>>))
|
||||
import Control.Monad.Hefty (Eff, interpret, interpretStateBy, raiseUnder, type (~>))
|
||||
import Control.Monad.Hefty.State (runState)
|
||||
import Control.Monad.Hefty.Writer (handleTell)
|
||||
import Data.Effect.Output (Output (Output))
|
||||
import Data.Effect.Output
|
||||
import Data.Effect.State (modify)
|
||||
import Data.Effect.Writer (Tell (Tell))
|
||||
|
||||
|
@ -7,7 +7,11 @@ Copyright : (c) 2024 Sayo Koyoneda
|
||||
License : MPL-2.0 (see the LICENSE file)
|
||||
Maintainer : ymdfield@outlook.jp
|
||||
-}
|
||||
module Control.Monad.Hefty.Provider where
|
||||
module Control.Monad.Hefty.Provider (
|
||||
module Control.Monad.Hefty.Provider,
|
||||
module Data.Effect.Provider,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Monad.Hefty (
|
||||
Eff,
|
||||
@ -23,8 +27,7 @@ import Control.Monad.Hefty (
|
||||
type (~>),
|
||||
)
|
||||
import Data.Effect.Key (KeyH (KeyH))
|
||||
import Data.Effect.Provider (Provider, Provider' (Provide), ProviderKey)
|
||||
import Data.Effect.Provider qualified as P
|
||||
import Data.Effect.Provider
|
||||
import Data.Effect.Tag (type (#), type (##))
|
||||
import Data.Functor.Identity (Identity (Identity))
|
||||
|
||||
@ -62,7 +65,7 @@ runProvider_
|
||||
-> Eff (ProviderFix_ i eh rh ef rf ': rh) rf ~> Eff rh rf
|
||||
runProvider_ run = runProvider \i m -> run i $ Identity <$> m
|
||||
|
||||
provide
|
||||
scope
|
||||
:: forall tag ctx i eh ef a sh bh sf bf
|
||||
. ( MemberHBy
|
||||
(ProviderKey ctx i)
|
||||
@ -75,11 +78,11 @@ provide
|
||||
-> Eff (sh ## tag ': ProviderFix ctx i sh bh sf bf ': bh) (sf # tag ': bf) a
|
||||
)
|
||||
-> Eff eh ef (ctx a)
|
||||
provide i f =
|
||||
i P...! \runInBase ->
|
||||
scope i f =
|
||||
i ..! \runInBase ->
|
||||
ProviderBase . untag . untagH $ f $ tagH . tag . unProviderBase . runInBase
|
||||
|
||||
provide_
|
||||
scope_
|
||||
:: forall tag i eh ef a sh bh sf bf
|
||||
. ( MemberHBy
|
||||
(ProviderKey Identity i)
|
||||
@ -92,6 +95,6 @@ provide_
|
||||
-> Eff (sh ## tag ': ProviderFix_ i sh bh sf bf ': bh) (sf # tag ': bf) a
|
||||
)
|
||||
-> Eff eh ef a
|
||||
provide_ i f =
|
||||
i P..! \runInBase ->
|
||||
scope_ i f =
|
||||
i .! \runInBase ->
|
||||
ProviderBase . untag . untagH $ f $ tagH . tag . unProviderBase . runInBase
|
||||
|
@ -10,7 +10,11 @@ Portability : portable
|
||||
|
||||
Interpreters for the t'Ask' / t'Local' effects.
|
||||
-}
|
||||
module Control.Monad.Hefty.Reader where
|
||||
module Control.Monad.Hefty.Reader (
|
||||
module Control.Monad.Hefty.Reader,
|
||||
module Data.Effect.Reader,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Monad.Hefty (
|
||||
Eff,
|
||||
@ -22,7 +26,7 @@ import Control.Monad.Hefty (
|
||||
type (~>),
|
||||
type (~~>),
|
||||
)
|
||||
import Data.Effect.Reader (Ask (..), Local (..), ask)
|
||||
import Data.Effect.Reader
|
||||
|
||||
runReader
|
||||
:: forall r eh ef
|
||||
|
@ -12,16 +12,21 @@ Portability : portable
|
||||
|
||||
An elaborator for the t'Control.Effect.Class.Resource.Resource' effect class.
|
||||
-}
|
||||
module Control.Monad.Hefty.Resource where
|
||||
module Control.Monad.Hefty.Resource (
|
||||
module Control.Monad.Hefty.Resource,
|
||||
module Data.Effect.Resource,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Effect (type (~>))
|
||||
import Control.Monad.Hefty.Interpret (interpretH)
|
||||
import Control.Monad.Hefty.Types (Eff, type (~~>))
|
||||
import Data.Effect.OpenUnion.Internal.FO (type (<|))
|
||||
import Data.Effect.OpenUnion.Internal.HO (type (<<|))
|
||||
import Data.Effect.Resource (Resource (Bracket, BracketOnExcept))
|
||||
import Data.Effect.Resource
|
||||
import Data.Effect.Unlift (UnliftIO)
|
||||
import UnliftIO (MonadUnliftIO, bracket, bracketOnError)
|
||||
import UnliftIO (MonadUnliftIO)
|
||||
import UnliftIO qualified as IO
|
||||
|
||||
-- | Elaborates the `Resource` effect under the `UnliftIO` context.
|
||||
runResourceIO
|
||||
@ -31,6 +36,6 @@ runResourceIO = interpretH elabResourceIO
|
||||
|
||||
elabResourceIO :: (MonadUnliftIO m) => Resource ~~> m
|
||||
elabResourceIO = \case
|
||||
Bracket acquire release thing -> bracket acquire release thing
|
||||
BracketOnExcept acquire onError thing -> bracketOnError acquire onError thing
|
||||
Bracket acquire release thing -> IO.bracket acquire release thing
|
||||
BracketOnExcept acquire onError thing -> IO.bracketOnError acquire onError thing
|
||||
{-# INLINE elabResourceIO #-}
|
||||
|
@ -2,7 +2,11 @@
|
||||
-- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
-- file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
module Control.Monad.Hefty.ShiftReset where
|
||||
module Control.Monad.Hefty.ShiftReset (
|
||||
module Control.Monad.Hefty.ShiftReset,
|
||||
module Data.Effect.ShiftReset,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Monad.Hefty (
|
||||
Eff,
|
||||
@ -14,13 +18,7 @@ import Control.Monad.Hefty (
|
||||
type (~>),
|
||||
)
|
||||
import Data.Effect.Key (KeyH (KeyH))
|
||||
import Data.Effect.ShiftReset (
|
||||
Reset (Reset),
|
||||
Shift,
|
||||
Shift' (Shift),
|
||||
Shift_,
|
||||
Shift_' (Shift_'),
|
||||
)
|
||||
import Data.Effect.ShiftReset
|
||||
|
||||
type ShiftFix ans eh ef = Shift ans (ShiftBase ans eh ef)
|
||||
|
||||
|
@ -10,7 +10,11 @@ Portability : portable
|
||||
|
||||
Interpreter for the t'Data.Effect.State.State' effect.
|
||||
-}
|
||||
module Control.Monad.Hefty.State where
|
||||
module Control.Monad.Hefty.State (
|
||||
module Control.Monad.Hefty.State,
|
||||
module Data.Effect.State,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Arrow ((>>>))
|
||||
import Control.Monad.Hefty (
|
||||
@ -30,7 +34,7 @@ import Control.Monad.Hefty (
|
||||
)
|
||||
import Control.Monad.Hefty.Reader (runAsk)
|
||||
import Data.Effect.Reader (Ask (Ask), ask)
|
||||
import Data.Effect.State (State (Get, Put), get, put)
|
||||
import Data.Effect.State
|
||||
import Data.Functor ((<&>))
|
||||
import UnliftIO (newIORef, readIORef, writeIORef)
|
||||
|
||||
|
@ -8,10 +8,14 @@ License : MPL-2.0 (see the LICENSE file)
|
||||
Maintainer : ymdfield@outlook.jp
|
||||
Portability : portable
|
||||
-}
|
||||
module Control.Monad.Hefty.Unlift where
|
||||
module Control.Monad.Hefty.Unlift (
|
||||
module Control.Monad.Hefty.Unlift,
|
||||
module Data.Effect.Unlift,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Monad.Hefty (Eff, interpretH, runEff, send0, type (~>))
|
||||
import Data.Effect.Unlift (UnliftBase (WithRunInBase), UnliftIO)
|
||||
import Data.Effect.Unlift
|
||||
|
||||
runUnliftBase :: forall b. (Monad b) => Eff '[UnliftBase b] '[b] ~> b
|
||||
runUnliftBase =
|
||||
|
@ -13,7 +13,11 @@ Portability : portable
|
||||
Interpreter and elaborator for the t'Data.Effect.Writer.Writer' effect class.
|
||||
See [README.md](https://github.com/sayo-hs/heftia/blob/master/README.md).
|
||||
-}
|
||||
module Control.Monad.Hefty.Writer where
|
||||
module Control.Monad.Hefty.Writer (
|
||||
module Control.Monad.Hefty.Writer,
|
||||
module Data.Effect.Writer,
|
||||
)
|
||||
where
|
||||
|
||||
import Control.Monad.Hefty (
|
||||
Eff,
|
||||
@ -26,7 +30,7 @@ import Control.Monad.Hefty (
|
||||
type (<|),
|
||||
type (~>),
|
||||
)
|
||||
import Data.Effect.Writer (Tell (Tell), WriterH (Censor, Listen), tell)
|
||||
import Data.Effect.Writer
|
||||
|
||||
-- | 'Writer' effect handler with post-applying censor semantics.
|
||||
runWriterPost :: (Monoid w) => Eff '[WriterH w] (Tell w ': ef) a -> Eff '[] ef (w, a)
|
||||
@ -45,23 +49,23 @@ handleTell (Tell w') w k = k (w <> w') ()
|
||||
|
||||
runWriterHPost :: (Monoid w, Tell w <| ef) => Eff '[WriterH w] ef ~> Eff '[] ef
|
||||
runWriterHPost = interpretH \case
|
||||
Listen m -> listen m
|
||||
Listen m -> intercept m
|
||||
Censor f m -> censorPost f m
|
||||
|
||||
runWriterHPre :: (Monoid w, Tell w <| ef) => Eff '[WriterH w] ef ~> Eff '[] ef
|
||||
runWriterHPre = interpretH \case
|
||||
Listen m -> listen m
|
||||
Listen m -> intercept m
|
||||
Censor f m -> censorPre f m
|
||||
|
||||
{- | Retrieves the monoidal value accumulated by v'tell' within the given action.
|
||||
The v'tell' effect is not consumed and remains intact.
|
||||
-}
|
||||
listen
|
||||
intercept
|
||||
:: forall w ef a
|
||||
. (Tell w <| ef, Monoid w)
|
||||
=> Eff '[] ef a
|
||||
-> Eff '[] ef (w, a)
|
||||
listen =
|
||||
intercept =
|
||||
interposeStateBy @_ @(Tell w)
|
||||
mempty
|
||||
(curry pure)
|
||||
|
Loading…
Reference in New Issue
Block a user