on master help sign in
Prefer MonadIO to MonadBase and MonadUnliftIO to MonadBaseControl
d0a8a41Andrzej Rybczak
src/Effectful/Internal/Monad.hs+11−7
@@ -272,8 +272,8 @@ tryFailIO tag m =
272----------------------------------------
272----------------------------------------
273-- IO
273-- IO
274
274
275−-- | Run arbitrary 'IO' operations via 'MonadIO', 'MonadBaseControl' 'IO' or
275+-- | Run arbitrary 'IO' operations via 'MonadIO', 'MonadUnliftIO' or
276−-- 'MonadUnliftIO'.
276+-- 'MonadBaseControl' 'IO'.
277newtype IOE :: Effect where
277newtype IOE :: Effect where
278 IOE :: UnliftStrategy -> IOE m r
278 IOE :: UnliftStrategy -> IOE m r
279
279
@@ -286,17 +286,21 @@ runIOE m = unEff (evalEffect (IdE (IOE SeqUnlift)) m) =<< emptyEnv
286instance IOE :> es => MonadIO (Eff es) where
286instance IOE :> es => MonadIO (Eff es) where
287 liftIO = unsafeEff_
287 liftIO = unsafeEff_
288
288
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.
289instance IOE :> es => MonadBase IO (Eff es) where
294instance IOE :> es => MonadBase IO (Eff es) where
290 liftBase = unsafeEff_
295 liftBase = unsafeEff_
291
296
297+-- | Instance included for compatibility with existing code, usage of
298+-- 'withRunInIO' is preferrable.
292instance IOE :> es => MonadBaseControl IO (Eff es) where
299instance IOE :> es => MonadBaseControl IO (Eff es) where
293 type StM (Eff es) a = a
300 type StM (Eff es) a = a
294 liftBaseWith = unliftEff
301 liftBaseWith = unliftEff
295 restoreM = pure
302 restoreM = pure
296
303
297−instance IOE :> es => MonadUnliftIO (Eff es) where
298− withRunInIO = unliftEff
299−
300----------------------------------------
304----------------------------------------
301-- Primitive
305-- Primitive
302
306
@@ -315,8 +319,8 @@ instance PrimE :> es => PrimMonad (Eff es) where
315----------------------------------------
319----------------------------------------
316-- Unlift strategies
320-- Unlift strategies
317
321
318−-- | The strategy to use when unlifting 'Eff' operations via 'liftBaseWith',
322+-- | The strategy to use when unlifting 'Eff' operations via 'withRunInIO',
319−-- 'withRunInIO' or the 'Effectful.Interpreter.localUnlift' family.
323+-- 'liftBaseWith' or the 'Effectful.Interpreter.localUnlift' family.
320data UnliftStrategy
324data UnliftStrategy
321 = SeqUnlift
325 = SeqUnlift
322 -- ^ The fastest strategy and a default setting for 'IOE'. An attempt to call
326 -- ^ The fastest strategy and a default setting for 'IOE'. An attempt to call