Rename runCatch to unliftCatch.

main
Rob Rix 2019-07-15 16:02:09 -04:00
parent 44ff4aeb25
commit 06a867679d
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7
1 changed files with 5 additions and 6 deletions

View File

@ -13,7 +13,6 @@ module Control.Effect.Catch
( Catch (..) ( Catch (..)
, catch , catch
, catchSync , catchSync
, runCatch
, withCatch , withCatch
, CatchC (..) , CatchC (..)
) where ) where
@ -63,10 +62,10 @@ catchSync f g = f `catch` \e ->
else liftIO (Exc.throw e) else liftIO (Exc.throw e)
-- | Evaluate a 'Catch' effect. -- | Evaluate a 'Catch' effect.
runCatch :: (forall x . m x -> IO x) unliftCatch :: (forall x . m x -> IO x)
-> CatchC m a -> CatchC m a
-> m a -> m a
runCatch handler = runReader (Handler handler) . runCatchC unliftCatch handler = runReader (Handler handler) . runCatchC
-- | Evaluate a 'Catch' effect, using 'MonadUnliftIO' to infer a correct -- | Evaluate a 'Catch' effect, using 'MonadUnliftIO' to infer a correct
-- unlifting function. -- unlifting function.
@ -83,7 +82,7 @@ newtype CatchC m a = CatchC { runCatchC :: ReaderC (Handler m) m a }
instance MonadUnliftIO m => MonadUnliftIO (CatchC m) where instance MonadUnliftIO m => MonadUnliftIO (CatchC m) where
askUnliftIO = CatchC . ReaderC $ \(Handler h) -> askUnliftIO = CatchC . ReaderC $ \(Handler h) ->
withUnliftIO $ \u -> pure (UnliftIO $ \r -> unliftIO u (runCatch h r)) withUnliftIO $ \u -> pure (UnliftIO $ \r -> unliftIO u (unliftCatch h r))
instance (Carrier sig m, MonadIO m) => Carrier (Catch :+: sig) (CatchC m) where instance (Carrier sig m, MonadIO m) => Carrier (Catch :+: sig) (CatchC m) where
eff (L (CatchIO act cleanup k)) = do eff (L (CatchIO act cleanup k)) = do