on master help sign in
Safer and more descriptive API for static dispatch
commitf749af5d39e8e2dfdb7b7092d7839f2f30b4baa7 authorAndrzej Rybczak <andrzej@rybczak.net> dateSat 25 Dec 2021, 16:20 (5 years ago) parent28ee6e4
18 files changed+87−87
effectful-core/src/Effectful/Dispatch/Dynamic.hs+2−2 effectful-core/src/Effectful/Dispatch/Static.hs+9−9 effectful-core/src/Effectful/Error.hs+3−3 effectful-core/src/Effectful/Internal/Effect.hs+3−3 effectful-core/src/Effectful/Internal/Monad.hs+31−31 effectful-core/src/Effectful/Reader.hs+3−3 effectful-core/src/Effectful/State/Local.hs+8−8 effectful-core/src/Effectful/State/Shared.hs+7−7 effectful-core/src/Effectful/Writer/Local.hs+5−5 effectful-core/src/Effectful/Writer/Shared.hs+5−5 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
effectful-core/src/Effectful/Dispatch/Dynamic.hs+2−2
@@ -49,7 +49,7 @@ interpret
4949 -> Eff es a
5050interpret handler m = unsafeEff $ \es -> do
5151 les <- forkEnv es
52− (`unEff` es) $ runHandlerA (HandlerA les handler) m
52+ (`unEff` es) $ runHandler (HandlerA les handler) m
5353
5454-- | Interpret an effect using other effects.
5555reinterpret
@@ -62,7 +62,7 @@ reinterpret
6262reinterpret runHandlerEs handler m = unsafeEff $ \es -> do
6363 les0 <- forkEnv es
6464 (`unEff` les0) . runHandlerEs . unsafeEff $ \les -> do
65− (`unEff` es) $ runHandlerA (HandlerA les handler) m
65+ (`unEff` es) $ runHandler (HandlerA les handler) m
6666
6767----------------------------------------
6868-- Unlifts
effectful-core/src/Effectful/Dispatch/Static.hs+9−9
@@ -1,18 +1,18 @@
11module Effectful.Dispatch.Static
22 ( -- * Low level API
3− IdA(..)
3+ DataA(..)
44
55 -- ** Running
6− , runEffect
7− , evalEffect
8− , execEffect
6+ , runData
7+ , evalData
8+ , execData
99
1010 -- ** Modification
11− , getEffect
12− , putEffect
13− , stateEffect
14− , stateEffectM
15− , localEffect
11+ , getData
12+ , putData
13+ , stateData
14+ , stateDataM
15+ , localData
1616
1717 -- ** Unlifts
1818 , seqUnliftIO
effectful-core/src/Effectful/Error.hs+3−3
@@ -102,7 +102,7 @@ runError
102102runError m = unsafeEff $ \es0 -> mask $ \release -> do
103103 eid <- newErrorId
104104 size0 <- sizeEnv es0
105− es <- unsafeConsEnv (IdA (Error @e eid)) noRelinker es0
105+ es <- unsafeConsEnv (DataA (Error @e eid)) noRelinker es0
106106 r <- tryErrorIO release eid es `onException` unsafeTailEnv size0 es
107107 unsafeTailEnv size0 es
108108 pure r
@@ -119,7 +119,7 @@ throwError
119119 -- ^ The error.
120120 -> Eff es a
121121throwError e = unsafeEff $ \es -> do
122− IdA (Error eid) <- getEnv @(Error e) es
122+ DataA (Error eid) <- getEnv @(Error e) es
123123 throwIO $ ErrorEx eid callStack e
124124
125125-- | Handle an error of type @e@.
@@ -131,7 +131,7 @@ catchError
131131 -- ^ A handler for errors in the inner computation.
132132 -> Eff es a
133133catchError m handler = unsafeEff $ \es -> do
134− IdA (Error eid) <- getEnv @(Error e) es
134+ DataA (Error eid) <- getEnv @(Error e) es
135135 size <- sizeEnv es
136136 catchErrorIO eid (unEff m es) $ \cs e -> do
137137 checkSizeEnv size es
effectful-core/src/Effectful/Internal/Effect.hs+3−3
@@ -8,7 +8,7 @@
88module Effectful.Internal.Effect
99 ( Effect
1010 , (:>)(..)
11− , IdA(..)
11+ , DataA(..)
1212
1313 -- * Utils
1414 , SuffixOf
@@ -24,8 +24,8 @@ import GHC.TypeLits
2424type Effect = (Type -> Type) -> Type -> Type
2525
2626-- | An adapter for statically dispatched effects.
27−newtype IdA :: Effect -> Type where
28− IdA :: (forall m r. e m r) -> IdA e
27+newtype DataA :: Effect -> Type where
28+ DataA :: (forall m r. e m r) -> DataA e
2929
3030-- | A constraint that requires that a particular effect @e@ is a member of the
3131-- type-level list @es@. This is used to parameterize an 'Effectful.Monad.Eff'
effectful-core/src/Effectful/Internal/Monad.hs+31−31
@@ -44,7 +44,7 @@ module Effectful.Internal.Monad
4444 , EffectHandler
4545 , LocalEnv(..)
4646 , HandlerA(..)
47− , runHandlerA
47+ , runHandler
4848
4949 -- *** Sending operations
5050 , send
@@ -52,16 +52,16 @@ module Effectful.Internal.Monad
5252 -- ** Primitive
5353
5454 -- *** Running
55− , runEffect
56− , evalEffect
57− , execEffect
55+ , runData
56+ , evalData
57+ , execData
5858
5959 -- *** Modification
60− , getEffect
61− , putEffect
62− , stateEffect
63− , stateEffectM
64− , localEffect
60+ , getData
61+ , putData
62+ , stateData
63+ , stateDataM
64+ , localData
6565 ) where
6666
6767import Control.Applicative (liftA2)
@@ -151,12 +151,12 @@ unsafeEff_ m = unsafeEff $ \_ -> m
151151-- | Get the current 'UnliftStrategy'.
152152unliftStrategy :: IOE :> es => Eff es UnliftStrategy
153153unliftStrategy = do
154− IdA (IOE unlift) <- getEffect
154+ DataA (IOE unlift) <- getData
155155 pure unlift
156156
157157-- | Locally override the 'UnliftStrategy' with the given value.
158158withUnliftStrategy :: IOE :> es => UnliftStrategy -> Eff es a -> Eff es a
159−withUnliftStrategy unlift = localEffect $ \_ -> IdA (IOE unlift)
159+withUnliftStrategy unlift = localData $ \_ -> DataA (IOE unlift)
160160
161161-- | Create an unlifting function with the current 'UnliftStrategy'.
162162--
@@ -272,7 +272,7 @@ newtype IOE :: Effect where
272272--
273273-- For running pure computations see 'runPureEff'.
274274runEff :: Eff '[IOE] a -> IO a
275−runEff m = unEff (evalEffect (IdA (IOE SeqUnlift)) m) =<< emptyEnv
275+runEff m = unEff (evalData (DataA (IOE SeqUnlift)) m) =<< emptyEnv
276276
277277instance IOE :> es => MonadIO (Eff es) where
278278 liftIO = unsafeEff_
@@ -302,7 +302,7 @@ data Prim :: Effect where
302302
303303-- | Run an 'Eff' computation with primitive state-transformer actions.
304304runPrim :: IOE :> es => Eff (Prim : es) a -> Eff es a
305−runPrim = evalEffect (IdA Prim)
305+runPrim = evalData (DataA Prim)
306306
307307instance Prim :> es => PrimMonad (Eff es) where
308308 type PrimState (Eff es) = RealWorld
@@ -338,8 +338,8 @@ data HandlerA :: Effect -> Type where
338338 HandlerA :: !(Env es) -> !(EffectHandler e es) -> HandlerA e
339339
340340-- | 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
341+runHandler :: HandlerA e -> Eff (e : es) a -> Eff es a
342+runHandler e m = unsafeEff $ \es0 -> do
343343 size0 <- sizeEnv es0
344344 E.bracket (unsafeConsEnv e relinker es0)
345345 (unsafeTailEnv size0)
@@ -359,44 +359,44 @@ send op = unsafeEff $ \es -> do
359359----------------------------------------
360360-- Helpers
361361
362−runEffect :: adapter e -> Eff (e : es) a -> Eff es (a, adapter e)
363−runEffect e0 m = unsafeEff $ \es0 -> do
362+runData :: DataA e -> Eff (e : es) a -> Eff es (a, DataA e)
363+runData e0 m = unsafeEff $ \es0 -> do
364364 size0 <- sizeEnv es0
365365 E.bracket (unsafeConsEnv e0 noRelinker es0)
366366 (unsafeTailEnv size0)
367367 (\es -> (,) <$> unEff m es <*> getEnv es)
368368
369−evalEffect :: adapter e -> Eff (e : es) a -> Eff es a
370−evalEffect e m = unsafeEff $ \es0 -> do
369+evalData :: DataA e -> Eff (e : es) a -> Eff es a
370+evalData e m = unsafeEff $ \es0 -> do
371371 size0 <- sizeEnv es0
372372 E.bracket (unsafeConsEnv e noRelinker es0)
373373 (unsafeTailEnv size0)
374374 (\es -> unEff m es)
375375
376−execEffect :: adapter e -> Eff (e : es) a -> Eff es (adapter e)
377−execEffect e0 m = unsafeEff $ \es0 -> do
376+execData :: DataA e -> Eff (e : es) a -> Eff es (DataA e)
377+execData e0 m = unsafeEff $ \es0 -> do
378378 size0 <- sizeEnv es0
379379 E.bracket (unsafeConsEnv e0 noRelinker es0)
380380 (unsafeTailEnv size0)
381381 (\es -> unEff m es *> getEnv es)
382382
383−getEffect :: e :> es => Eff es (adapter e)
384−getEffect = unsafeEff $ \es -> getEnv es
383+getData :: e :> es => Eff es (DataA e)
384+getData = unsafeEff $ \es -> getEnv es
385385
386−putEffect :: e :> es => adapter e -> Eff es ()
387−putEffect e = unsafeEff $ \es -> putEnv es e
386+putData :: e :> es => DataA e -> Eff es ()
387+putData e = unsafeEff $ \es -> putEnv es e
388388
389−stateEffect :: e :> es => (adapter e -> (a, adapter e)) -> Eff es a
390−stateEffect f = unsafeEff $ \es -> stateEnv es f
389+stateData :: e :> es => (DataA e -> (a, DataA e)) -> Eff es a
390+stateData f = unsafeEff $ \es -> stateEnv es f
391391
392−stateEffectM :: e :> es => (adapter e -> Eff es (a, adapter e)) -> Eff es a
393−stateEffectM f = unsafeEff $ \es -> E.mask $ \release -> do
392+stateDataM :: e :> es => (DataA e -> Eff es (a, DataA e)) -> Eff es a
393+stateDataM f = unsafeEff $ \es -> E.mask $ \release -> do
394394 (a, e) <- (\e -> release $ unEff (f e) es) =<< getEnv es
395395 putEnv es e
396396 pure a
397397
398−localEffect :: e :> es => (adapter e -> adapter e) -> Eff es a -> Eff es a
399−localEffect f m = unsafeEff $ \es -> do
398+localData :: e :> es => (DataA e -> DataA e) -> Eff es a -> Eff es a
399+localData f m = unsafeEff $ \es -> do
400400 E.bracket (stateEnv es $ \e -> (e, f e))
401401 (\e -> putEnv es e)
402402 (\_ -> 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 = evalEffect (IdA (Reader r))
23+runReader r = evalData (DataA (Reader r))
2424
2525-- | Fetch the value of the environment.
2626ask :: Reader r :> es => Eff es r
2727ask = do
28− IdA (Reader r) <- getEffect
28+ DataA (Reader r) <- getData
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 = localEffect $ \(IdA (Reader r)) -> IdA (Reader (f r))
49+local f = localData $ \(DataA (Reader r)) -> DataA (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, IdA (State s)) <- runEffect (IdA (State s0)) m
55+ (a, DataA (State s)) <- runData (DataA (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 = evalEffect (IdA (State s))
64+evalState s = evalData (DataA (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− IdA (State s) <- execEffect (IdA (State s0)) m
73+ DataA (State s) <- execData (DataA (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− IdA (State s) <- getEffect
79+ DataA (State s) <- getData
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 = putEffect (IdA (State s))
93+put s = putData (DataA (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 = stateEffect $ \(IdA (State s0)) -> let (a, s) = f s0 in (a, IdA (State s))
100+state f = stateData $ \(DataA (State s0)) -> let (a, s) = f s0 in (a, DataA (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 = stateEffectM $ \(IdA (State s0)) -> do
116+stateM f = stateDataM $ \(DataA (State s0)) -> do
117117 (a, s) <- f s0
118− pure (a, IdA (State s))
118+ pure (a, DataA (State s))
119119
120120-- | Apply the monadic function to the current state.
121121--
effectful-core/src/Effectful/State/Shared.hs+7−7
@@ -52,7 +52,7 @@ newtype State s :: Effect where
5252runState :: s -> Eff (State s : es) a -> Eff es (a, s)
5353runState s m = do
5454 v <- unsafeEff_ $ newMVar s
55− a <- evalEffect (IdA (State v)) m
55+ a <- evalData (DataA (State v)) m
5656 (a, ) <$> unsafeEff_ (readMVar v)
5757
5858-- | Run a 'State' effect with the given initial state and return the final
@@ -60,20 +60,20 @@ runState s m = do
6060evalState :: s -> Eff (State s : es) a -> Eff es a
6161evalState s m = do
6262 v <- unsafeEff_ $ newMVar s
63− evalEffect (IdA (State v)) m
63+ evalData (DataA (State v)) m
6464
6565-- | Run a 'State' effect with the given initial state and return the final
6666-- state, discarding the final value.
6767execState :: s -> Eff (State s : es) a -> Eff es s
6868execState s m = do
6969 v <- unsafeEff_ $ newMVar s
70− _ <- evalEffect (IdA (State v)) m
70+ _ <- evalData (DataA (State v)) m
7171 unsafeEff_ $ readMVar v
7272
7373-- | Fetch the current value of the state.
7474get :: State s :> es => Eff es s
7575get = unsafeEff $ \es -> do
76− IdA (State v) <- getEnv es
76+ DataA (State v) <- getEnv es
7777 readMVar v
7878
7979-- | Get a function of the current state.
@@ -85,7 +85,7 @@ gets f = f <$> get
8585-- | Set the current state to the given value.
8686put :: State s :> es => s -> Eff es ()
8787put s = unsafeEff $ \es -> do
88− IdA (State v) <- getEnv es
88+ DataA (State v) <- getEnv es
8989 modifyMVar_ v $ \_ -> s `seq` pure s
9090
9191-- | Apply the function to the current state and return a value.
@@ -93,7 +93,7 @@ put s = unsafeEff $ \es -> do
9393-- /Note:/ this function gets an exclusive access to the state for its duration.
9494state :: State s :> es => (s -> (a, s)) -> Eff es a
9595state f = unsafeEff $ \es -> do
96− IdA (State v) <- getEnv es
96+ DataA (State v) <- getEnv es
9797 modifyMVar v $ \s0 -> let (a, s) = f s0 in s `seq` pure (s, a)
9898
9999-- | Apply the function to the current state.
@@ -109,7 +109,7 @@ modify f = state (\s -> ((), f s))
109109-- /Note:/ this function gets an exclusive access to the state for its duration.
110110stateM :: State s :> es => (s -> Eff es (a, s)) -> Eff es a
111111stateM f = unsafeEff $ \es -> do
112− IdA (State v) <- getEnv es
112+ DataA (State v) <- getEnv es
113113 modifyMVar v $ \s0 -> do
114114 (a, s) <- unEff (f s0) es
115115 s `seq` pure (s, a)
effectful-core/src/Effectful/Writer/Local.hs+5−5
@@ -38,19 +38,19 @@ newtype Writer w :: Effect where
3838-- output.
3939runWriter :: Monoid w => Eff (Writer w : es) a -> Eff es (a, w)
4040runWriter m = do
41− (a, IdA (Writer w)) <- runEffect (IdA (Writer mempty)) m
41+ (a, DataA (Writer w)) <- runData (DataA (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− IdA (Writer w) <- execEffect (IdA (Writer mempty)) m
48+ DataA (Writer w) <- execData (DataA (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 = stateEffect $ \(IdA (Writer w0)) -> ((), IdA (Writer (w0 <> w)))
53+tell w = stateData $ \(DataA (Writer w0)) -> ((), DataA (Writer (w0 <> w)))
5454
5555-- | Execute an action and append its output to the overall output of the
5656-- 'Writer'.
@@ -71,13 +71,13 @@ tell w = stateEffect $ \(IdA (Writer w0)) -> ((), IdA (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 $ \(IdA (Writer w)) -> (w, IdA (Writer mempty))
74+ w0 <- stateEnv es $ \(DataA (Writer w)) -> (w, DataA (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 $ \(IdA (Writer w1)) -> (w1, IdA (Writer (w0 <> w1)))
80+ stateEnv es $ \(DataA (Writer w1)) -> (w1, DataA (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
effectful-core/src/Effectful/Writer/Shared.hs+5−5
@@ -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 <- evalEffect (IdA (Writer v)) m
42+ a <- evalData (DataA (Writer v)) m
4343 (a, ) <$> unsafeEff_ (readMVar v)
4444
4545-- | Run a 'Writer' effect and return the final output, discarding the final
@@ -47,13 +47,13 @@ runWriter m = do
4747execWriter :: Monoid w => Eff (Writer w : es) a -> Eff es w
4848execWriter m = do
4949 v <- unsafeEff_ $ newMVar mempty
50− _ <- evalEffect (IdA (Writer v)) m
50+ _ <- evalData (DataA (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− IdA (Writer v) <- getEnv es
56+ DataA (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
@@ -81,14 +81,14 @@ listen m = unsafeEff $ \es -> do
8181 uninterruptibleMask $ \restore -> do
8282 v1 <- newMVar mempty
8383 -- Replace thread local MVar with a fresh one for isolated listening.
84− v0 <- stateEnv es $ \(IdA (Writer v)) -> (v, IdA (Writer v1))
84+ v0 <- stateEnv es $ \(DataA (Writer v)) -> (v, DataA (Writer v1))
8585 a <- restore (unEff m es) `onException` merge es v0 v1
8686 (a, ) <$> merge es v0 v1
8787 where
8888 -- Merge results accumulated in the local MVar with the mainline. If an
8989 -- exception was received while listening, merge results recorded so far.
9090 merge es v0 v1 = do
91− putEnv es $ IdA (Writer v0)
91+ putEnv es $ DataA (Writer v0)
9292 w1 <- readMVar v1
9393 modifyMVar_ v0 $ \w0 -> let w = w0 <> w1 in w `seq` pure w
9494 pure w1
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 = evalEffect (IdA Concurrent)
75+runConcurrent = evalData (DataA 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 = evalEffect (IdA Environment)
31+runEnvironment = evalData (DataA 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 = evalEffect (IdA FileSystem)
103+runFileSystem = evalData (DataA 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 = evalEffect (IdA FileSystem)
15+runFileSystem = evalData (DataA 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 = evalEffect (IdA Process)
61+runProcess = evalData (DataA 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 (IdA (Resource istate)) noRelinker es0
40+ es <- unsafeConsEnv (DataA (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− IdA (Resource istate) <- getEffect
55+ DataA (Resource istate) <- getData
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 = evalEffect $ IdA (Resource istate)
62+runInternalState istate = evalData (DataA (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 >>= \(IdA (Resource istate)) -> m istate
69+ getEnv es >>= \(DataA (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 = evalEffect (IdA Temporary)
22+runTemporary = evalData (DataA 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 = evalEffect (IdA Timeout)
18+runTimeout = evalData (DataA Timeout)
1919
2020-- | Lifted 'T.timeout'.
2121timeout