on bf25f34 help sign in
24 files changed+184−258
since splitsnapshots
unifiedsplit
.github/workflows/haskell-ci.yml+5 README.md+2−2 effectful-core/effectful-core.cabal+1−1 effectful-core/src/Effectful/Dispatch/Dynamic.hs+3−15 effectful-core/src/Effectful/Dispatch/Static.hs+21−18 effectful-core/src/Effectful/Error.hs+6−36 effectful-core/src/Effectful/Internal/Effect.hs+17−1 effectful-core/src/Effectful/Internal/Env.hs+20−25 effectful-core/src/Effectful/Internal/Monad.hs+56−69 effectful-core/src/Effectful/Reader.hs+3−3 effectful-core/src/Effectful/State/Local.hs+8−8 effectful-core/src/Effectful/State/Shared.hs+8−31 effectful-core/src/Effectful/Writer/Local.hs+9−9 effectful-core/src/Effectful/Writer/Shared.hs+10−25 effectful/bench/Main.hs+3−3 effectful/effectful.cabal+1−1 effectful/src/Effectful/Concurrent/Effect.hs+1−1 effectful/src/Effectful/Environment.hs+1−1 effectful/src/Effectful/FileSystem.hs+1−1 effectful/src/Effectful/FileSystem/Effect.hs+1−1 effectful/src/Effectful/Process.hs+1−1 effectful/src/Effectful/Resource.hs+4−4 effectful/src/Effectful/Temporary.hs+1−1 effectful/src/Effectful/Timeout.hs+1−1
.github/workflows/haskell-ci.yml+5
@@ -37,6 +37,11 @@ jobs:
3737 compilerVersion: 9.2.1
3838 setup-method: ghcup
3939 allow-failure: false
40+ - compiler: ghc-9.0.1
41+ compilerKind: ghc
42+ compilerVersion: 9.0.1
43+ setup-method: hvr-ppa
44+ allow-failure: false
4045 - compiler: ghc-8.10.7
4146 compilerKind: ghc
4247 compilerVersion: 8.10.7
README.md+2−2
@@ -20,8 +20,8 @@ Main features:
2020
21212. Easy to use API (no boilerplate code and dealing with arcane types).
2222
23−3. Correct semantics in presence of runtime exceptions (no more lost state
24− modifications).
23+3. Correct semantics in presence of runtime exceptions (no more lost or
24+ discarded state).
2525
26264. Seamless integration with the existing ecosystem (`exceptions`,
2727 `monad-control`, `unliftio-core`, `resourcet` etc.).
effectful-core/effectful-core.cabal+1−1
@@ -18,7 +18,7 @@ description: An easy to use, performant extensible effects library with seamless
1818
1919extra-source-files: CHANGELOG.md
2020
21−tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.2.1
21+tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.0.1 || ==9.2.1
2222
2323bug-reports: https://github.com/arybczak/effectful/issues
2424source-repository head
effectful-core/src/Effectful/Dispatch/Dynamic.hs+3−15
@@ -32,8 +32,7 @@ module Effectful.Dispatch.Dynamic
3232 ) where
3333
3434import Control.Monad.IO.Unlift
35−import Data.Kind
36−import GHC.Stack (HasCallStack)
35+import GHC.Stack
3736
3837import Effectful.Internal.Effect
3938import Effectful.Internal.Env
@@ -50,7 +49,7 @@ interpret
5049 -> Eff es a
5150interpret handler m = unsafeEff $ \es -> do
5251 les <- forkEnv es
53− (`unEff` es) $ runHandler (HandlerA les handler) m
52+ (`unEff` es) $ runHandlerA (HandlerA les handler) m
5453
5554-- | Interpret an effect using other effects.
5655reinterpret
@@ -63,7 +62,7 @@ reinterpret
6362reinterpret runHandlerEs handler m = unsafeEff $ \es -> do
6463 les0 <- forkEnv es
6564 (`unEff` les0) . runHandlerEs . unsafeEff $ \les -> do
66− (`unEff` es) $ runHandler (HandlerA les handler) m
65+ (`unEff` es) $ runHandlerA (HandlerA les handler) m
6766
6867----------------------------------------
6968-- Unlifts
@@ -231,16 +230,5 @@ localLiftUnliftIO (LocalEnv les) strategy k = case strategy of
231230 SeqUnlift -> liftIO $ seqUnliftIO les $ k unsafeEff_
232231 ConcUnlift p l -> liftIO $ concUnliftIO les p l $ k unsafeEff_
233232
234−----------------------------------------
235−-- Utils
236−
237−-- | Require that the second list of effects is a suffix of the first one.
238−--
239−-- In other words, 'SuffixOf' @es@ @baseEs@ means "a suffix of @es@ is
240−-- @baseEs@".
241−type family SuffixOf (es :: [Effect]) (baseEs :: [Effect]) :: Constraint where
242− SuffixOf baseEs baseEs = ()
243− SuffixOf (e : es) baseEs = SuffixOf es baseEs
244−
245233-- $setup
246234-- >>> import Control.Concurrent
effectful-core/src/Effectful/Dispatch/Static.hs+21−18
@@ -1,30 +1,23 @@
11module Effectful.Dispatch.Static
22 ( -- * Low level API
3− DataA(..)
3+ IdA(..)
44
5− -- ** Extending the environment
6− , runData
7− , evalData
8− , execData
5+ -- ** Running
6+ , runEffect
7+ , evalEffect
8+ , execEffect
99
10− -- ** Data retrieval and update
11− , getData
12− , putData
13− , stateData
14− , stateDataM
15− , localData
10+ -- ** Modification
11+ , getEffect
12+ , putEffect
13+ , stateEffect
14+ , stateEffectM
15+ , localEffect
1616
1717 -- ** Unlifts
1818 , seqUnliftIO
1919 , concUnliftIO
2020
21− -- ** Utils
22− , unEff
23− , unsafeEff
24− , unsafeEff_
25− , unsafeLiftMapIO
26− , unsafeUnliftIO
27−
2821 -- * Primitive API
2922 , Env
3023 , Relinker(..)
@@ -46,8 +39,18 @@ module Effectful.Dispatch.Static
4639 , putEnv
4740 , stateEnv
4841 , modifyEnv
42+
43+ -- * Unsafe 'Eff' operations
44+ , unsafeEff
45+ , unsafeEff_
46+ , unsafeLiftMapIO
47+ , unsafeUnliftIO
48+
49+ -- * Utils
50+ , unEff
4951 ) where
5052
53+import Effectful.Internal.Effect
5154import Effectful.Internal.Env
5255import Effectful.Internal.Monad
5356
effectful-core/src/Effectful/Error.hs+6−36
@@ -1,6 +1,8 @@
11-- | Support for handling errors of a particular type, i.e. checked exceptions.
22--
3−-- The 'Error' effect is __not__ a general mechanism for handling regular
3+-- /Note:/ the 'Error' effect is a suitable replacement for the
4+-- 'Control.Monad.Trans.Except.ExceptT' monad transformer from the
5+-- @transformers@ library. It is __not__ a general mechanism for handling
46-- exceptions, that's what functions from the @exceptions@ library are for (see
57-- "Control.Monad.Catch" for more information).
68--
@@ -35,38 +37,6 @@
3537-- Cleaning up.
3638-- Left "oops"
3739--
38−-- /Note:/ unlike the 'Control.Monad.Trans.Except.ExceptT' monad transformer
39−-- from the @transformers@ library, the order in which you handle the 'Error'
40−-- effect with regard to other stateful effects does not matter. Consider the
41−-- following:
42−--
43−-- >>> import qualified Control.Monad.State.Strict as T
44−-- >>> import qualified Control.Monad.Except as T
45−--
46−-- >>> let m1 = (T.modify (++ " there!") >> T.throwError "oops") `T.catchError` \_ -> pure ()
47−--
48−-- >>> (`T.runStateT` "Hi") . T.runExceptT $ m1
49−-- (Right (),"Hi there!")
50−--
51−-- >>> T.runExceptT . (`T.runStateT` "Hi") $ m1
52−-- Right ((),"Hi")
53−--
54−-- Here, whether state modifications within the @catchError@ block are lost or
55−-- not depends on the shape of the monad transformer stack, which is surprising
56−-- and can be a source of subtle bugs. On the other hand:
57−--
58−-- >>> import Effectful.State.Local
59−--
60−-- >>> let m2 = (modify (++ " there!") >> throwError "oops") `catchError` \_ (_::String) -> pure ()
61−--
62−-- >>> runEff . runState "Hi" . runError @String $ m2
63−-- (Right (),"Hi there!")
64−--
65−-- >>> runEff . runError @String . runState "Hi" $ m2
66−-- Right ((),"Hi there!")
67−--
68−-- Here, no matter the order of effects, state modifications within the
69−-- @catchError@ block always persist, giving predictable behavior.
7040module Effectful.Error
7141 ( Error
7242 , runError
@@ -102,7 +72,7 @@ runError
10272runError m = unsafeEff $ \es0 -> mask $ \release -> do
10373 eid <- newErrorId
10474 size0 <- sizeEnv es0
105− es <- unsafeConsEnv (DataA (Error @e eid)) noRelinker es0
75+ es <- unsafeConsEnv (IdA (Error @e eid)) noRelinker es0
10676 r <- tryErrorIO release eid es `onException` unsafeTailEnv size0 es
10777 unsafeTailEnv size0 es
10878 pure r
@@ -119,7 +89,7 @@ throwError
11989 -- ^ The error.
12090 -> Eff es a
12191throwError e = unsafeEff $ \es -> do
122− DataA (Error eid) <- getEnv @(Error e) es
92+ IdA (Error eid) <- getEnv @(Error e) es
12393 throwIO $ ErrorEx eid callStack e
12494
12595-- | Handle an error of type @e@.
@@ -131,7 +101,7 @@ catchError
131101 -- ^ A handler for errors in the inner computation.
132102 -> Eff es a
133103catchError m handler = unsafeEff $ \es -> do
134− DataA (Error eid) <- getEnv @(Error e) es
104+ IdA (Error eid) <- getEnv @(Error e) es
135105 size <- sizeEnv es
136106 catchErrorIO eid (unEff m es) $ \cs e -> do
137107 checkSizeEnv size es
effectful-core/src/Effectful/Internal/Effect.hs+17−1
@@ -8,6 +8,10 @@
88module Effectful.Internal.Effect
99 ( Effect
1010 , (:>)(..)
11+ , IdA(..)
12+
13+ -- * Utils
14+ , SuffixOf
1115
1216 -- * Re-exports
1317 , Type
@@ -19,6 +23,10 @@ import GHC.TypeLits
1923-- | The kind of effects.
2024type Effect = (Type -> Type) -> Type -> Type
2125
26+-- | An adapter for statically dispatched effects.
27+newtype IdA :: Effect -> Type where
28+ IdA :: (forall m r. e m r) -> IdA e
29+
2230-- | A constraint that requires that a particular effect @e@ is a member of the
2331-- type-level list @es@. This is used to parameterize an 'Effectful.Monad.Eff'
2432-- computation over an arbitrary list of effects, so long as @e@ is /somewhere/
@@ -28,7 +36,7 @@ type Effect = (Type -> Type) -> Type -> Type
2836-- 'Integer' would likely use the following type:
2937--
3038-- @
31−-- 'Effectful.State.Local.State' 'Integer' ':>' es => 'Effectful.Monad.Eff' es ()
39+-- 'Effectful.State.State' 'Integer' ':>' es => 'Effectful.Monad.Eff' es ()
3240-- @
3341class (e :: Effect) :> (es :: [Effect]) where
3442 -- | Get the position of @e@ in @es@.
@@ -51,3 +59,11 @@ instance {-# OVERLAPPING #-} e :> (e : es) where
5159
5260instance e :> es => e :> (x : es) where
5361 reifyIndex = 1 + reifyIndex @e @es
62+
63+-- | Require that the second list of effects is a suffix of the first one.
64+--
65+-- In other words, 'SuffixOf' @es@ @baseEs@ means "a suffix of @es@ is
66+-- @baseEs@".
67+type family SuffixOf (es :: [Effect]) (baseEs :: [Effect]) :: Constraint where
68+ SuffixOf baseEs baseEs = ()
69+ SuffixOf (e : es) baseEs = SuffixOf es baseEs
effectful-core/src/Effectful/Internal/Env.hs+20−25
@@ -1,4 +1,3 @@
1−{-# LANGUAGE MagicHash #-}
21{-# OPTIONS_HADDOCK not-home #-}
32-- | The environment for the 'Effectful.Internal.Monad.Eff' monad.
43--
@@ -43,7 +42,7 @@ import Control.Monad
4342import Control.Monad.Primitive
4443import Data.IORef
4544import Data.Primitive.SmallArray
46−import GHC.Exts (Any, SmallMutableArray#)
45+import GHC.Exts (Any)
4746import GHC.Stack (HasCallStack)
4847import Unsafe.Coerce
4948import qualified Data.IntMap.Strict as IM
@@ -418,43 +417,43 @@ unsafeTailEnv len (Env fork gref _) = case fork of
418417
419418-- | Extract a specific data type from the environment.
420419getEnv
421− :: forall e adapter es. e :> es
420+ :: forall e es adapter. e :> es
422421 => Env es
423422 -> IO (adapter e)
424423getEnv env = do
425− Location i es <- getLocation (reifyIndex @e @es) env
424+ (i, es) <- getLocation (reifyIndex @e @es) env
426425 fromAny <$> readSmallArray es i
427426
428427-- | Replace the data type in the environment with a new value (in place).
429428putEnv
430− :: forall e adapter es. e :> es
429+ :: forall e es adapter. e :> es
431430 => Env es
432431 -> adapter e
433432 -> IO ()
434433putEnv env e = do
435− Location i es <- getLocation (reifyIndex @e @es) env
434+ (i, es) <- getLocation (reifyIndex @e @es) env
436435 e `seq` writeSmallArray es i (toAny e)
437436
438437-- | Modify the data type in the environment (in place) and return a value.
439438stateEnv
440− :: forall e adapter es a. e :> es
439+ :: forall e es adapter a. e :> es
441440 => Env es
442441 -> (adapter e -> (a, adapter e))
443442 -> IO a
444443stateEnv env f = do
445− Location i es <- getLocation (reifyIndex @e @es) env
444+ (i, es) <- getLocation (reifyIndex @e @es) env
446445 (a, e) <- f . fromAny <$> readSmallArray es i
447446 e `seq` writeSmallArray es i (toAny e)
448447 pure a
449448
450449-- | Modify the data type in the environment (in place).
451450modifyEnv
452− :: forall e adapter es. e :> es
451+ :: forall e es adapter. e :> es
453452 => Env es
454453 -> (adapter e -> adapter e)
455454 -> IO ()
456455modifyEnv env f = do
457− Location i es <- getLocation (reifyIndex @e @es) env
456+ (i, es) <- getLocation (reifyIndex @e @es) env
458457 e <- f . fromAny <$> readSmallArray es i
459458 e `seq` writeSmallArray es i (toAny e)
460459
@@ -470,17 +469,13 @@ emptyEnvRef = do
470469 fs <- newSmallArray 0 undefinedData
471470 newIORef $ EnvRef 0 es fs
472471
473−-- | Location with unboxed fields to make GHC generate Core without unnecessary
474−-- reboxing around the local 'go' function from 'getLocation'.
475−data Location = Location !Int !(SmallMutableArray RealWorld Any)
476−
477472-- | Determine location of the data type in the environment.
478473getLocation
479474 :: Int
480475 -> Env es
481− -> IO Location
476+ -> IO (Int, SmallMutableArray RealWorld Any)
482477getLocation ixE (Env fork ref _) = do
483− EnvRef n es@(SmallMutableArray es#) _ <- readIORef ref
478+ EnvRef n es _ <- readIORef ref
484479 -- Optimized for the common access pattern:
485480 --
486481 -- - Most application code has no access to forks, in which case we look at
@@ -489,25 +484,25 @@ getLocation ixE (Env fork ref _) = do
489484 -- - Effect handlers will most likely access the newest fork with handler
490485 -- specific effects for reinterpretation.
491486 case fork of
492− NoFork -> pure $ Location (ix n) es
487+ NoFork -> pure (ix n, es)
493488 Forks _ baseIx lref forks -> do
494489 EnvRef ln les _ <- readIORef lref
495490 let i = ix (baseIx + ln)
496491 if i >= baseIx
497− then pure $ Location (i - baseIx) les
498− else go es# i forks
492+ then pure (i - baseIx, les)
493+ else go es i forks
499494 where
500− go :: SmallMutableArray# RealWorld Any
495+ go :: SmallMutableArray RealWorld Any
501496 -> Int
502497 -> Forks
503− -> IO Location
504− go es# i = \case
505− NoFork -> pure $ Location i (SmallMutableArray es#)
498+ -> IO (Int, SmallMutableArray RealWorld Any)
499+ go es i = \case
500+ NoFork -> pure (i, es)
506501 Forks _ baseIx lref forks -> do
507502 EnvRef _ les _ <- readIORef lref
508503 if i >= baseIx
509− then pure $ Location (i - baseIx) les
510− else go es# i forks
504+ then pure (i - baseIx, les)
505+ else go es i forks
511506
512507 ix :: Int -> Int
513508 ix n = n - ixE - 1
effectful-core/src/Effectful/Internal/Monad.hs+56−69
@@ -6,7 +6,7 @@
66-- This module is intended for internal use only, and may change without warning
77-- in subsequent releases.
88module Effectful.Internal.Monad
9− ( -- * The 'Eff' monad
9+ ( -- * Monad
1010 Eff
1111 , runPureEff
1212
@@ -22,11 +22,11 @@ module Effectful.Internal.Monad
2222 , IOE
2323 , runEff
2424
25− -- * Prim
25+ -- * Primitive
2626 , Prim
2727 , runPrim
2828
29− -- * Unlift strategies
29+ -- ** Unlift strategies
3030 , UnliftStrategy(..)
3131 , Persistence(..)
3232 , Limit(..)
@@ -34,29 +34,34 @@ module Effectful.Internal.Monad
3434 , withUnliftStrategy
3535 , withEffToIO
3636
37− -- ** Low-level unlifts
37+ --- *** Low-level helpers
3838 , seqUnliftIO
3939 , concUnliftIO
4040
4141 -- * Effects
4242
43− -- ** Dynamic dispatch
43+ -- ** Handler
4444 , EffectHandler
4545 , LocalEnv(..)
4646 , HandlerA(..)
47− , runHandler
47+ , runHandlerA
48+
49+ -- *** Sending operations
4850 , send
4951
50− -- ** Static dispatch
51− , DataA(..)
52− , runData
53− , evalData
54− , execData
55− , getData
56− , putData
57− , stateData
58− , stateDataM
59− , localData
52+ -- ** Primitive
53+
54+ -- *** Running
55+ , runEffect
56+ , evalEffect
57+ , execEffect
58+
59+ -- *** Modification
60+ , getEffect
61+ , putEffect
62+ , stateEffect
63+ , stateEffectM
64+ , localEffect
6065 ) where
6166
6267import Control.Applicative (liftA2)
@@ -87,16 +92,17 @@ type role Eff nominal representational
8792-- would have the following type:
8893--
8994-- @
90−-- 'Eff' '['Effectful.Reader.Reader' 'String', 'Effectful.State.Local.State' 'Bool'] 'Integer'
95+-- 'Eff' '['Effectful.Reader.Reader' 'String', 'Effectful.State.State' 'Bool'] 'Integer'
9196-- @
9297--
9398-- Normally, a concrete list of effects is not used to parameterize 'Eff'.
9499-- Instead, the '(:>)' type class is used to express constraints on the list of
95100-- effects without coupling a computation to a concrete list of effects. For
96−-- example, the above example would be expressed with the following type:
101+-- example, the above example would more commonly be expressed with the
102+-- following type:
97103--
98104-- @
99−-- ('Effectful.Reader.Reader' 'String' ':>' es, 'Effectful.State.Local.State' 'Bool' ':>' es) => 'Eff' es 'Integer'
105+-- ('Effectful.Reader.Reader' 'String' ':>' es, 'Effectful.State.State' 'Bool' ':>' es) => 'Eff' es 'Integer'
100106-- @
101107--
102108-- This abstraction allows the computation to be used in functions that may
@@ -110,12 +116,12 @@ newtype Eff (es :: [Effect]) a = Eff (Env es -> IO a)
110116-- For running computations with side effects see 'runEff'.
111117runPureEff :: Eff '[] a -> a
112118runPureEff (Eff m) =
113− -- unsafeDupablePerformIO is safe here since IOE was not on the stack, so no
114− -- IO with side effects was performed (unless someone sneakily introduced side
115− -- effects with unsafeEff, but then all bets are off).
119+ -- unsafePerformIO is safe here since IOE was not on the stack, so no IO with
120+ -- side effects was performed (unless someone sneakily introduced side effects
121+ -- with unsafeEff, but then all bets are off).
116122 --
117123 -- Moreover, internals don't allocate any resources that require explicit
118− -- cleanup actions to run.
124+ -- cleanup actions to run, so the "Dupable" part should also be just fine.
119125 unsafeDupablePerformIO $ m =<< emptyEnv
120126
121127----------------------------------------
@@ -145,12 +151,12 @@ unsafeEff_ m = unsafeEff $ \_ -> m
145151-- | Get the current 'UnliftStrategy'.
146152unliftStrategy :: IOE :> es => Eff es UnliftStrategy
147153unliftStrategy = do
148− DataA (IOE unlift) <- getData
154+ IdA (IOE unlift) <- getEffect
149155 pure unlift
150156
151157-- | Locally override the 'UnliftStrategy' with the given value.
152158withUnliftStrategy :: IOE :> es => UnliftStrategy -> Eff es a -> Eff es a
153−withUnliftStrategy unlift = localData $ \_ -> DataA (IOE unlift)
159+withUnliftStrategy unlift = localEffect $ \_ -> IdA (IOE unlift)
154160
155161-- | Create an unlifting function with the current 'UnliftStrategy'.
156162--
@@ -158,7 +164,7 @@ withUnliftStrategy unlift = localData $ \_ -> DataA (IOE unlift)
158164-- constraint for accurate stack traces in case an insufficiently powerful
159165-- 'UnliftStrategy' is used and the unlifting function fails.
160166--
161−-- /Note:/ the strategy is reset to 'SeqUnlift' inside the continuation.
167+-- /Note:/ the strategy is reset to 'SeqUnlift' for new threads.
162168withEffToIO
163169 :: (HasCallStack, IOE :> es)
164170 => ((forall r. Eff es r -> IO r) -> IO a)
@@ -266,7 +272,7 @@ newtype IOE :: Effect where
266272--
267273-- For running pure computations see 'runPureEff'.
268274runEff :: Eff '[IOE] a -> IO a
269−runEff m = unEff (evalData (DataA (IOE SeqUnlift)) m) =<< emptyEnv
275+runEff m = unEff (evalEffect (IdA (IOE SeqUnlift)) m) =<< emptyEnv
270276
271277instance IOE :> es => MonadIO (Eff es) where
272278 liftIO = unsafeEff_
@@ -296,14 +302,14 @@ data Prim :: Effect where
296302
297303-- | Run an 'Eff' computation with primitive state-transformer actions.
298304runPrim :: IOE :> es => Eff (Prim : es) a -> Eff es a
299−runPrim = evalData (DataA Prim)
305+runPrim = evalEffect (IdA Prim)
300306
301307instance Prim :> es => PrimMonad (Eff es) where
302308 type PrimState (Eff es) = RealWorld
303309 primitive = unsafeEff_ . IO
304310
305311----------------------------------------
306−-- Dynamic dispatch
312+-- Handler
307313
308314type role LocalEnv nominal nominal
309315
@@ -327,13 +333,13 @@ type EffectHandler e es
327333
328334-- | An adapter for dynamically dispatched effects.
329335--
330−-- Represents the effect handler bundled with its environment.
336+-- Represents the effect handler bundled along with its environment.
331337data HandlerA :: Effect -> Type where
332338 HandlerA :: !(Env es) -> !(EffectHandler e es) -> HandlerA e
333339
334−-- | Run a dynamically dispatched effect with the given handler.
335−runHandler :: HandlerA e -> Eff (e : es) a -> Eff es a
336−runHandler e m = unsafeEff $ \es0 -> do
340+-- | Run the effect with the given handler.
341+runHandlerA :: HandlerA e -> Eff (e : es) a -> Eff es a
342+runHandlerA e m = unsafeEff $ \es0 -> do
337343 size0 <- sizeEnv es0
338344 E.bracket (unsafeConsEnv e relinker es0)
339345 (unsafeTailEnv size0)
@@ -351,65 +357,46 @@ send op = unsafeEff $ \es -> do
351357 unEff (handle (LocalEnv es) op) handlerEs
352358
353359----------------------------------------
354−-- Static dispatch
360+-- Helpers
355361
356−-- | An adapter for statically dispatched effects.
357−--
358−-- Represents an arbitrary data type with the appropriate number of phantom type
359−-- parameters.
360−newtype DataA :: Effect -> Type where
361− DataA :: (forall m r. e m r) -> DataA e
362−
363−-- | Run a statically dispatched effect with the given initial state and return
364−-- the final value along with the final state.
365−runData :: DataA e -> Eff (e : es) a -> Eff es (a, DataA e)
366−runData e0 m = unsafeEff $ \es0 -> do
362+runEffect :: adapter e -> Eff (e : es) a -> Eff es (a, adapter e)
363+runEffect e0 m = unsafeEff $ \es0 -> do
367364 size0 <- sizeEnv es0
368365 E.bracket (unsafeConsEnv e0 noRelinker es0)
369366 (unsafeTailEnv size0)
370367 (\es -> (,) <$> unEff m es <*> getEnv es)
371368
372−-- | Run a statically dispatched effect with the given initial state and return
373−-- the final value, discarding the final state.
374−evalData :: DataA e -> Eff (e : es) a -> Eff es a
375−evalData e m = unsafeEff $ \es0 -> do
369+evalEffect :: adapter e -> Eff (e : es) a -> Eff es a
370+evalEffect e m = unsafeEff $ \es0 -> do
376371 size0 <- sizeEnv es0
377372 E.bracket (unsafeConsEnv e noRelinker es0)
378373 (unsafeTailEnv size0)
379374 (\es -> unEff m es)
380375
381−-- | Run a statically dispatched effect with the given initial state and return
382−-- the final state, discarding the final value.
383−execData :: DataA e -> Eff (e : es) a -> Eff es (DataA e)
384−execData e0 m = unsafeEff $ \es0 -> do
376+execEffect :: adapter e -> Eff (e : es) a -> Eff es (adapter e)
377+execEffect e0 m = unsafeEff $ \es0 -> do
385378 size0 <- sizeEnv es0
386379 E.bracket (unsafeConsEnv e0 noRelinker es0)
387380 (unsafeTailEnv size0)
388381 (\es -> unEff m es *> getEnv es)
389382
390−-- | Fetch the current state of the effect.
391−getData :: e :> es => Eff es (DataA e)
392−getData = unsafeEff $ \es -> getEnv es
383+getEffect :: e :> es => Eff es (adapter e)
384+getEffect = unsafeEff $ \es -> getEnv es
393385
394−-- | Set the current state of the effect to the given value.
395−putData :: e :> es => DataA e -> Eff es ()
396−putData e = unsafeEff $ \es -> putEnv es e
386+putEffect :: e :> es => adapter e -> Eff es ()
387+putEffect e = unsafeEff $ \es -> putEnv es e
397388
398−-- | Apply the function to the current state of the effect and return a value.
399−stateData :: e :> es => (DataA e -> (a, DataA e)) -> Eff es a
400−stateData f = unsafeEff $ \es -> stateEnv es f
389+stateEffect :: e :> es => (adapter e -> (a, adapter e)) -> Eff es a
390+stateEffect f = unsafeEff $ \es -> stateEnv es f
401391
402−-- | Apply the monadic function to the current state of the effect and return a
403−-- value.
404−stateDataM :: e :> es => (DataA e -> Eff es (a, DataA e)) -> Eff es a
405−stateDataM f = unsafeEff $ \es -> E.mask $ \release -> do
392+stateEffectM :: e :> es => (adapter e -> Eff es (a, adapter e)) -> Eff es a
393+stateEffectM f = unsafeEff $ \es -> E.mask $ \release -> do
406394 (a, e) <- (\e -> release $ unEff (f e) es) =<< getEnv es
407395 putEnv es e
408396 pure a
409397
410−-- | Execute a computation with a temporarily modified state of the effect.
411−localData :: e :> es => (DataA e -> DataA e) -> Eff es a -> Eff es a
412−localData f m = unsafeEff $ \es -> do
398+localEffect :: e :> es => (adapter e -> adapter e) -> Eff es a -> Eff es a
399+localEffect f m = unsafeEff $ \es -> do
413400 E.bracket (stateEnv es $ \e -> (e, f e))
414401 (\e -> putEnv es e)
415402 (\_ -> unEff m es)
effectful-core/src/Effectful/Reader.hs+3−3
@@ -20,12 +20,12 @@ runReader
2020 :: r -- ^ An initial environment.
2121 -> Eff (Reader r : es) a
2222 -> Eff es a
23−runReader r = evalData (DataA (Reader r))
23+runReader r = evalEffect (IdA (Reader r))
2424
2525-- | Fetch the value of the environment.
2626ask :: Reader r :> es => Eff es r
2727ask = do
28− DataA (Reader r) <- getData
28+ IdA (Reader r) <- getEffect
2929 pure r
3030
3131-- | Retrieve a function of the current environment.
@@ -46,4 +46,4 @@ local
4646 => (r -> r) -- ^ The function to modify the environment.
4747 -> Eff es a
4848 -> Eff es a
49−local f = localData $ \(DataA (Reader r)) -> DataA (Reader (f r))
49+local f = localEffect $ \(IdA (Reader r)) -> IdA (Reader (f r))
effectful-core/src/Effectful/State/Local.hs+8−8
@@ -52,7 +52,7 @@ runState
5252 -> Eff (State s : es) a
5353 -> Eff es (a, s)
5454runState s0 m = do
55− (a, DataA (State s)) <- runData (DataA (State s0)) m
55+ (a, IdA (State s)) <- runEffect (IdA (State s0)) m
5656 pure (a, s)
5757
5858-- | Run a 'State' effect with the given initial state and return the final
@@ -61,7 +61,7 @@ evalState
6161 :: s -- ^ An initial state.
6262 -> Eff (State s : es) a
6363 -> Eff es a -- ^ A return value.
64−evalState s = evalData (DataA (State s))
64+evalState s = evalEffect (IdA (State s))
6565
6666-- | Run a 'State' effect with the given initial state and return the final
6767-- state, discarding the final value.
@@ -70,13 +70,13 @@ execState
7070 -> Eff (State s : es) a
7171 -> Eff es s
7272execState s0 m = do
73− DataA (State s) <- execData (DataA (State s0)) m
73+ IdA (State s) <- execEffect (IdA (State s0)) m
7474 pure s
7575
7676-- | Fetch the current value of the state.
7777get :: State s :> es => Eff es s
7878get = do
79− DataA (State s) <- getData
79+ IdA (State s) <- getEffect
8080 pure s
8181
8282-- | Get a function of the current state.
@@ -90,14 +90,14 @@ gets f = f <$> get
9090
9191-- | Set the current state to the given value.
9292put :: State s :> es => s -> Eff es ()
93−put s = putData (DataA (State s))
93+put s = putEffect (IdA (State s))
9494
9595-- | Apply the function to the current state and return a value.
9696state
9797 :: State s :> es
9898 => (s -> (a, s)) -- ^ The function to modify the state.
9999 -> Eff es a
100−state f = stateData $ \(DataA (State s0)) -> let (a, s) = f s0 in (a, DataA (State s))
100+state f = stateEffect $ \(IdA (State s0)) -> let (a, s) = f s0 in (a, IdA (State s))
101101
102102-- | Apply the function to the current state.
103103--
@@ -113,9 +113,9 @@ stateM
113113 :: State s :> es
114114 => (s -> Eff es (a, s)) -- ^ The function to modify the state.
115115 -> Eff es a
116−stateM f = stateDataM $ \(DataA (State s0)) -> do
116+stateM f = stateEffectM $ \(IdA (State s0)) -> do
117117 (a, s) <- f s0
118− pure (a, DataA (State s))
118+ pure (a, IdA (State s))
119119
120120-- | Apply the monadic function to the current state.
121121--
effectful-core/src/Effectful/State/Shared.hs+8−31
@@ -3,27 +3,8 @@
33-- - shared between multiple threads (if you want each thead to manage its own
44-- version of the value, see "Effectful.State.Local").
55--
6−-- - slightly slower than "Effectful.State.Local".
6+-- - slower than "Effectful.State.Local".
77--
8−-- /Note:/ unlike the 'Control.Monad.Trans.State.StateT' monad transformer from
9−-- the @transformers@ library, the 'State' effect doesn't lose state
10−-- modifications when an exception is received:
11−--
12−-- >>> import qualified Control.Monad.Trans.State.Strict as S
13−--
14−-- >>> :{
15−-- (`S.execStateT` "Hi") . handle (\(_::ErrorCall) -> pure ()) $ do
16−-- S.modify (++ " there!")
17−-- error "oops"
18−-- :}
19−-- "Hi"
20−--
21−-- >>> :{
22−-- runEff . execState "Hi" . handle (\(_::ErrorCall) -> pure ()) $ do
23−-- modify (++ " there!")
24−-- error "oops"
25−-- :}
26−-- "Hi there!"
278module Effectful.State.Shared
289 ( State
2910 , runState
@@ -52,7 +33,7 @@ newtype State s :: Effect where
5233runState :: s -> Eff (State s : es) a -> Eff es (a, s)
5334runState s m = do
5435 v <- unsafeEff_ $ newMVar s
55− a <- evalData (DataA (State v)) m
36+ a <- evalEffect (IdA (State v)) m
5637 (a, ) <$> unsafeEff_ (readMVar v)
5738
5839-- | Run a 'State' effect with the given initial state and return the final
@@ -60,20 +41,20 @@ runState s m = do
6041evalState :: s -> Eff (State s : es) a -> Eff es a
6142evalState s m = do
6243 v <- unsafeEff_ $ newMVar s
63− evalData (DataA (State v)) m
44+ evalEffect (IdA (State v)) m
6445
6546-- | Run a 'State' effect with the given initial state and return the final
6647-- state, discarding the final value.
6748execState :: s -> Eff (State s : es) a -> Eff es s
6849execState s m = do
6950 v <- unsafeEff_ $ newMVar s
70− _ <- evalData (DataA (State v)) m
51+ _ <- evalEffect (IdA (State v)) m
7152 unsafeEff_ $ readMVar v
7253
7354-- | Fetch the current value of the state.
7455get :: State s :> es => Eff es s
7556get = unsafeEff $ \es -> do
76− DataA (State v) <- getEnv es
57+ IdA (State v) <- getEnv es
7758 readMVar v
7859
7960-- | Get a function of the current state.
@@ -85,7 +66,7 @@ gets f = f <$> get
8566-- | Set the current state to the given value.
8667put :: State s :> es => s -> Eff es ()
8768put s = unsafeEff $ \es -> do
88− DataA (State v) <- getEnv es
69+ IdA (State v) <- getEnv es
8970 modifyMVar_ v $ \_ -> s `seq` pure s
9071
9172-- | Apply the function to the current state and return a value.
@@ -93,7 +74,7 @@ put s = unsafeEff $ \es -> do
9374-- /Note:/ this function gets an exclusive access to the state for its duration.
9475state :: State s :> es => (s -> (a, s)) -> Eff es a
9576state f = unsafeEff $ \es -> do
96− DataA (State v) <- getEnv es
77+ IdA (State v) <- getEnv es
9778 modifyMVar v $ \s0 -> let (a, s) = f s0 in s `seq` pure (s, a)
9879
9980-- | Apply the function to the current state.
@@ -109,7 +90,7 @@ modify f = state (\s -> ((), f s))
10990-- /Note:/ this function gets an exclusive access to the state for its duration.
11091stateM :: State s :> es => (s -> Eff es (a, s)) -> Eff es a
11192stateM f = unsafeEff $ \es -> do
112− DataA (State v) <- getEnv es
93+ IdA (State v) <- getEnv es
11394 modifyMVar v $ \s0 -> do
11495 (a, s) <- unEff (f s0) es
11596 s `seq` pure (s, a)
@@ -121,7 +102,3 @@ stateM f = unsafeEff $ \es -> do
121102-- /Note:/ this function gets an exclusive access to the state for its duration.
122103modifyM :: State s :> es => (s -> Eff es s) -> Eff es ()
123104modifyM f = stateM (\s -> ((), ) <$> f s)
124−
125−-- $setup
126−-- >>> import Control.Exception (ErrorCall)
127−-- >>> import Control.Monad.Catch
effectful-core/src/Effectful/Writer/Local.hs+9−9
@@ -38,26 +38,26 @@ newtype Writer w :: Effect where
3838-- output.
3939runWriter :: Monoid w => Eff (Writer w : es) a -> Eff es (a, w)
4040runWriter m = do
41− (a, DataA (Writer w)) <- runData (DataA (Writer mempty)) m
41+ (a, IdA (Writer w)) <- runEffect (IdA (Writer mempty)) m
4242 pure (a, w)
4343
4444-- | Run a 'Writer' effect and return the final output, discarding the final
4545-- value.
4646execWriter :: Monoid w => Eff (Writer w : es) a -> Eff es w
4747execWriter m = do
48− DataA (Writer w) <- execData (DataA (Writer mempty)) m
48+ IdA (Writer w) <- execEffect (IdA (Writer mempty)) m
4949 pure w
5050
5151-- | Append the given output to the overall output of the 'Writer'.
5252tell :: (Writer w :> es, Monoid w) => w -> Eff es ()
53−tell w = stateData $ \(DataA (Writer w0)) -> ((), DataA (Writer (w0 <> w)))
53+tell w = stateEffect $ \(IdA (Writer w0)) -> ((), IdA (Writer (w0 <> w)))
5454
5555-- | Execute an action and append its output to the overall output of the
5656-- 'Writer'.
5757--
58−-- /Note:/ if an exception is received while the action is executed, the partial
59−-- output of the action will still be appended to the overall output of the
60−-- 'Writer':
58+-- /Note:/ if a runtime exception is received while the action is executed, the
59+-- partial output of the action will still be appended to the overall output of
60+-- the 'Writer':
6161--
6262-- >>> :{
6363-- runEff . execWriter @String $ do
@@ -71,13 +71,13 @@ tell w = stateData $ \(DataA (Writer w0)) -> ((), DataA (Writer (w0 <> w)))
7171-- "Hi there!"
7272listen :: (Writer w :> es, Monoid w) => Eff es a -> Eff es (a, w)
7373listen m = unsafeEff $ \es -> mask $ \restore -> do
74− w0 <- stateEnv es $ \(DataA (Writer w)) -> (w, DataA (Writer mempty))
74+ w0 <- stateEnv es $ \(IdA (Writer w)) -> (w, IdA (Writer mempty))
7575 a <- restore (unEff m es) `onException` merge es w0
7676 (a, ) <$> merge es w0
7777 where
7878 merge es w0 =
7979 -- If an exception is thrown, restore w0 and keep parts of w1.
80− stateEnv es $ \(DataA (Writer w1)) -> (w1, DataA (Writer (w0 <> w1)))
80+ stateEnv es $ \(IdA (Writer w1)) -> (w1, IdA (Writer (w0 <> w1)))
8181
8282-- | Execute an action and append its output to the overall output of the
8383-- 'Writer', then return the final value along with a function of the recorded
@@ -90,5 +90,5 @@ listens f m = do
9090 pure (a, f w)
9191
9292-- $setup
93−-- >>> import Control.Exception (ErrorCall)
9493-- >>> import Control.Monad.Catch
94+-- >>> import Control.Exception (ErrorCall)
effectful-core/src/Effectful/Writer/Shared.hs+10−25
@@ -3,7 +3,7 @@
33-- - shared between multiple threads (if you want each thead to manage its own
44-- version of the value, see "Effectful.Writer.Local").
55--
6−-- - slightly slower than "Effectful.Writer.Local".
6+-- - slower than "Effectful.Writer.Local".
77--
88-- /Warning:/ 'Writer'\'s state will be accumulated via __left-associated__ uses
99-- of '<>', which makes it unsuitable for use with types for which such pattern
@@ -25,7 +25,7 @@ module Effectful.Writer.Shared
2525 ) where
2626
2727import Control.Concurrent.MVar
28−import Control.Exception (onException, uninterruptibleMask)
28+import Control.Exception
2929
3030import Effectful.Dispatch.Static
3131import Effectful.Monad
@@ -39,7 +39,7 @@ newtype Writer w :: Effect where
3939runWriter :: Monoid w => Eff (Writer w : es) a -> Eff es (a, w)
4040runWriter m = do
4141 v <- unsafeEff_ $ newMVar mempty
42− a <- evalData (DataA (Writer v)) m
42+ a <- evalEffect (IdA (Writer v)) m
4343 (a, ) <$> unsafeEff_ (readMVar v)
4444
4545-- | Run a 'Writer' effect and return the final output, discarding the final
@@ -47,32 +47,21 @@ runWriter m = do
4747execWriter :: Monoid w => Eff (Writer w : es) a -> Eff es w
4848execWriter m = do
4949 v <- unsafeEff_ $ newMVar mempty
50− _ <- evalData (DataA (Writer v)) m
50+ _ <- evalEffect (IdA (Writer v)) m
5151 unsafeEff_ $ readMVar v
5252
5353-- | Append the given output to the overall output of the 'Writer'.
5454tell :: (Writer w :> es, Monoid w) => w -> Eff es ()
5555tell w1 = unsafeEff $ \es -> do
56− DataA (Writer v) <- getEnv es
56+ IdA (Writer v) <- getEnv es
5757 modifyMVar_ v $ \w0 -> let w = w0 <> w1 in w `seq` pure w
5858
5959-- | Execute an action and append its output to the overall output of the
6060-- 'Writer'.
6161--
62−-- /Note:/ if an exception is received while the action is executed, the partial
63−-- output of the action will still be appended to the overall output of the
64−-- 'Writer':
65−--
66−-- >>> :{
67−-- runEff . execWriter @String $ do
68−-- tell "Hi"
69−-- handle (\(_::ErrorCall) -> pure ((), "")) $ do
70−-- tell " there"
71−-- listen $ do
72−-- tell "!"
73−-- error "oops"
74−-- :}
75−-- "Hi there!"
62+-- /Note:/ if a runtime exception is received while the action is executed, the
63+-- partial output of the action will still be appended to the overall output of
64+-- the 'Writer'.
7665listen :: (Writer w :> es, Monoid w) => Eff es a -> Eff es (a, w)
7766listen m = unsafeEff $ \es -> do
7867 -- The mask is uninterruptible because modifyMVar_ v0 in the merge function
@@ -81,14 +70,14 @@ listen m = unsafeEff $ \es -> do
8170 uninterruptibleMask $ \restore -> do
8271 v1 <- newMVar mempty
8372 -- Replace thread local MVar with a fresh one for isolated listening.
84− v0 <- stateEnv es $ \(DataA (Writer v)) -> (v, DataA (Writer v1))
73+ v0 <- stateEnv es $ \(IdA (Writer v)) -> (v, IdA (Writer v1))
8574 a <- restore (unEff m es) `onException` merge es v0 v1
8675 (a, ) <$> merge es v0 v1
8776 where
8877 -- Merge results accumulated in the local MVar with the mainline. If an
8978 -- exception was received while listening, merge results recorded so far.
9079 merge es v0 v1 = do
91− putEnv es $ DataA (Writer v0)
80+ putEnv es $ IdA (Writer v0)
9281 w1 <- readMVar v1
9382 modifyMVar_ v0 $ \w0 -> let w = w0 <> w1 in w `seq` pure w
9483 pure w1
@@ -102,7 +91,3 @@ listens :: (Writer w :> es, Monoid w) => (w -> b) -> Eff es a -> Eff es (a, b)
10291listens f m = do
10392 (a, w) <- listen m
10493 pure (a, f w)
105−
106−-- $setup
107−-- >>> import Control.Exception (ErrorCall)
108−-- >>> import Control.Monad.Catch
effectful/bench/Main.hs+3−3
@@ -97,11 +97,11 @@ filesize n = bgroup (show n)
9797#ifdef VERSION_eff
9898 , bench "eff" $ nfAppIO eff_calculateFileSizesDeep (take n files)
9999#endif
100−#ifdef VERSION_mtl
101− , bench "mtl" $ nfAppIO mtl_calculateFileSizesDeep (take n files)
102−#endif
103100#ifdef VERSION_polysemy
104101 , bench "polysemy" $ nfAppIO poly_calculateFileSizesDeep (take n files)
102+#endif
103+#ifdef VERSION_mtl
104+ , bench "mtl" $ nfAppIO mtl_calculateFileSizesDeep (take n files)
105105#endif
106106 ]
107107 ]
effectful/effectful.cabal+1−1
@@ -20,7 +20,7 @@ description: An easy to use, performant extensible effects library with seamless
2020
2121extra-source-files: CHANGELOG.md
2222
23−tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.2.1
23+tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.0.1 || ==9.2.1
2424
2525bug-reports: https://github.com/arybczak/effectful/issues
2626source-repository head
effectful/src/Effectful/Concurrent/Effect.hs+1−1
@@ -72,7 +72,7 @@ data Concurrent :: Effect where
7272
7373-- | Run the 'Concurrent' effect.
7474runConcurrent :: IOE :> es => Eff (Concurrent : es) a -> Eff es a
75−runConcurrent = evalData (DataA Concurrent)
75+runConcurrent = evalEffect (IdA Concurrent)
7676
7777-- $setup
7878-- >>> import Effectful.Concurrent
effectful/src/Effectful/Environment.hs+1−1
@@ -28,7 +28,7 @@ data Environment :: Effect where
2828
2929-- | Run the 'Environment' effect.
3030runEnvironment :: IOE :> es => Eff (Environment : es) a -> Eff es a
31−runEnvironment = evalData (DataA Environment)
31+runEnvironment = evalEffect (IdA Environment)
3232
3333-- | Lifted 'E.getArgs'.
3434getArgs :: Environment :> es => Eff es [String]
effectful/src/Effectful/FileSystem.hs+1−1
@@ -100,7 +100,7 @@ data FileSystem :: Effect where
100100
101101-- | Run the 'FileSystem' effect.
102102runFileSystem :: IOE :> es => Eff (FileSystem : es) a -> Eff es a
103−runFileSystem = evalData (DataA FileSystem)
103+runFileSystem = evalEffect (IdA FileSystem)
104104
105105----------------------------------------
106106-- Actions on directories
effectful/src/Effectful/FileSystem/Effect.hs+1−1
@@ -12,4 +12,4 @@ data FileSystem :: Effect where
1212
1313-- | Run the 'FileSystem' effect.
1414runFileSystem :: IOE :> es => Eff (FileSystem : es) a -> Eff es a
15−runFileSystem = evalData (DataA FileSystem)
15+runFileSystem = evalEffect (IdA FileSystem)
effectful/src/Effectful/Process.hs+1−1
@@ -58,7 +58,7 @@ data Process :: Effect where
5858 Process :: Process m r
5959
6060runProcess :: IOE :> es => Eff (Process : es) a -> Eff es a
61−runProcess = evalData (DataA Process)
61+runProcess = evalEffect (IdA Process)
6262
6363----------------------------------------
6464-- Running sub-processes
effectful/src/Effectful/Resource.hs+4−4
@@ -37,7 +37,7 @@ runResource m = unsafeEff $ \es0 -> do
3737 size0 <- sizeEnv es0
3838 istate <- R.createInternalState
3939 mask $ \restore -> do
40− es <- unsafeConsEnv (DataA (Resource istate)) noRelinker es0
40+ es <- unsafeConsEnv (IdA (Resource istate)) noRelinker es0
4141 a <- restore (unEff m es) `catch` \e -> do
4242 unsafeTailEnv size0 es
4343 RI.stateCleanupChecked (Just e) istate
@@ -52,18 +52,18 @@ runResource m = unsafeEff $ \es0 -> do
5252-- | Get the 'R.InternalState' of the current 'Resource' effect.
5353getInternalState :: Resource :> es => Eff es R.InternalState
5454getInternalState = do
55− DataA (Resource istate) <- getData
55+ IdA (Resource istate) <- getEffect
5656 pure istate
5757
5858-- | Run the 'Resource' effect with existing 'R.InternalState'.
5959--
6060-- /Note:/ the 'R.InternalState' will not be closed at the end.
6161runInternalState :: R.InternalState -> Eff (Resource : es) a -> Eff es a
62−runInternalState istate = evalData (DataA (Resource istate))
62+runInternalState istate = evalEffect $ IdA (Resource istate)
6363
6464----------------------------------------
6565-- Orphan instance
6666
6767instance (IOE :> es, Resource :> es) => R.MonadResource (Eff es) where
6868 liftResourceT (RI.ResourceT m) = unsafeEff $ \es -> do
69− getEnv es >>= \(DataA (Resource istate)) -> m istate
69+ getEnv es >>= \(IdA (Resource istate)) -> m istate
effectful/src/Effectful/Temporary.hs+1−1
@@ -19,7 +19,7 @@ data Temporary :: Effect where
1919
2020-- | Run the 'Temporary' effect.
2121runTemporary :: IOE :> es => Eff (Temporary : es) a -> Eff es a
22−runTemporary = evalData (DataA Temporary)
22+runTemporary = evalEffect (IdA Temporary)
2323
2424-- | Lifted 'T.withSystemTempFile'.
2525withSystemTempFile
effectful/src/Effectful/Timeout.hs+1−1
@@ -15,7 +15,7 @@ data Timeout :: Effect where
1515
1616-- | Run the 'Timeout' effect.
1717runTimeout :: IOE :> es => Eff (Timeout : es) a -> Eff es a
18−runTimeout = evalData (DataA Timeout)
18+runTimeout = evalEffect (IdA Timeout)
1919
2020-- | Lifted 'T.timeout'.
2121timeout