packages feed

rescue 0.2.0 → 0.2.1

raw patch · 2 files changed

+23/−23 lines, 2 files

Files

library/Control/Monad/Trans/Rescue/Types.hs view
@@ -1,7 +1,9 @@-{-# LANGUAGE ApplicativeDo        #-}-{-# LANGUAGE LambdaCase           #-}-{-# LANGUAGE TypeFamilies         #-}-{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE ApplicativeDo         #-}+{-# LANGUAGE LambdaCase            #-}+{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies          #-}+{-# LANGUAGE UndecidableInstances  #-}  -- | The 'RescueT' transformer module Control.Monad.Trans.Rescue.Types@@ -13,6 +15,7 @@ import           Control.Monad.Catch import           Control.Monad.Cont import           Control.Monad.Fix+import           Control.Monad.Reader import           Control.Monad.Rescue  import           Data.Functor.Identity@@ -28,6 +31,11 @@ runRescue :: Rescue errs a -> Either (OpenUnion errs) a runRescue = runIdentity . runRescueT +mapRescueT+  :: (m (Either (OpenUnion errs)  a) -> n (Either (OpenUnion errs') b))+  -> RescueT errs m a -> RescueT errs' n b+mapRescueT f (RescueT m) = RescueT $ f m+ instance Eq (m (Either (OpenUnion errs) a)) => Eq (RescueT errs m a) where   RescueT a == RescueT b = a == b @@ -81,21 +89,13 @@ instance Monad m => MonadRescue (RescueT errs m) where   attempt (RescueT action) = RescueT (Right <$> action) -instance-  ( IsMember SomeException errs-  , Monad m-  )-  => MonadThrow (RescueT errs m) where-  throwM = RescueT . pure . Left . openUnionLift . toException+instance MonadThrow m => MonadThrow (RescueT errs m) where+  throwM = lift . throwM -instance-  ( IsMember SomeException errs-  , Contains errs errs-  , Monad m-  )-  => MonadCatch (RescueT errs m) where-  catch action handler =-    rescue action $ \errs ->-      case openUnionMatch errs of-        Nothing  -> raise errs-        Just err -> maybe (raise err) handler $ fromException err+instance MonadCatch m => MonadCatch (RescueT errs m) where+  catch (RescueT m) f = RescueT $ catch m (runRescueT . f)++instance MonadReader cfg m => MonadReader cfg (RescueT errs m) where+  ask    = lift ask+  local  = mapRescueT . local+  reader = lift . reader
rescue.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 70b533d152069a3c11b8c763cbf6104c93c199d3858df8f49c4564331744b375+-- hash: 3e4995b89bcb6d9791c2c448d52d59c9ca79e160013ba0d3fbad54936b417fe3  name:           rescue-version:        0.2.0+version:        0.2.1 synopsis:       More understandable exceptions description:    An error handling library focused on clarity and control category:       Error Handling