on master help sign in
Prefer MonadIO to MonadBase and MonadUnliftIO to MonadBaseControl
commitd0a8a419a5455c73ef5418f58f45536fe8d2526e authorAndrzej Rybczak <andrzej@rybczak.net> dateSun 11 Jul 2021, 22:03 (5 years ago) parent2d259c3
1 file changed+11−7
src/Effectful/Internal/Monad.hs+11−7
src/Effectful/Internal/Monad.hs+11−7
@@ -272,8 +272,8 @@ tryFailIO tag m =
272272----------------------------------------
273273-- IO
274274
275−-- | Run arbitrary 'IO' operations via 'MonadIO', 'MonadBaseControl' 'IO' or
276−-- 'MonadUnliftIO'.
275+-- | Run arbitrary 'IO' operations via 'MonadIO', 'MonadUnliftIO' or
276+-- 'MonadBaseControl' 'IO'.
277277newtype IOE :: Effect where
278278 IOE :: UnliftStrategy -> IOE m r
279279
@@ -286,17 +286,21 @@ runIOE m = unEff (evalEffect (IdE (IOE SeqUnlift)) m) =<< emptyEnv
286286instance IOE :> es => MonadIO (Eff es) where
287287 liftIO = unsafeEff_
288288
289+instance IOE :> es => MonadUnliftIO (Eff es) where
290+ withRunInIO = unliftEff
291+
292+-- | Instance included for compatibility with existing code, usage of 'liftIO'
293+-- is preferrable.
289294instance IOE :> es => MonadBase IO (Eff es) where
290295 liftBase = unsafeEff_
291296
297+-- | Instance included for compatibility with existing code, usage of
298+-- 'withRunInIO' is preferrable.
292299instance IOE :> es => MonadBaseControl IO (Eff es) where
293300 type StM (Eff es) a = a
294301 liftBaseWith = unliftEff
295302 restoreM = pure
296303
297−instance IOE :> es => MonadUnliftIO (Eff es) where
298− withRunInIO = unliftEff
299−
300304----------------------------------------
301305-- Primitive
302306
@@ -315,8 +319,8 @@ instance PrimE :> es => PrimMonad (Eff es) where
315319----------------------------------------
316320-- Unlift strategies
317321
318−-- | The strategy to use when unlifting 'Eff' operations via 'liftBaseWith',
319−-- 'withRunInIO' or the 'Effectful.Interpreter.localUnlift' family.
322+-- | The strategy to use when unlifting 'Eff' operations via 'withRunInIO',
323+-- 'liftBaseWith' or the 'Effectful.Interpreter.localUnlift' family.
320324data UnliftStrategy
321325 = SeqUnlift
322326 -- ^ The fastest strategy and a default setting for 'IOE'. An attempt to call