packages feed

exceptiot 0.0.1.0 → 0.0.1.1

raw patch · 5 files changed

+45/−4 lines, 5 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Control.Monad.Except.Catch: catchError :: MonadError e m => m a -> (e -> m a) -> m a
+ Control.Monad.Except.Catch: class Monad m => MonadError e (m :: Type -> Type) | m -> e
+ Control.Monad.Except.Catch: handleError :: MonadError e m => (e -> m a) -> m a -> m a
+ Control.Monad.Except.Catch: liftEither :: MonadError e m => Either e a -> m a
+ Control.Monad.Except.Catch: mapError :: (MonadError e m, MonadError e' n) => (m (Either e a) -> n (Either e' b)) -> m a -> n b
+ Control.Monad.Except.Catch: throwError :: MonadError e m => e -> m a
+ Control.Monad.Except.Catch: tryError :: MonadError e m => m a -> m (Either e a)
+ Control.Monad.Except.Catch: withError :: MonadError e m => (e -> e) -> m a -> m a
+ Control.Monad.Except.IO: catchError :: MonadError e m => m a -> (e -> m a) -> m a
+ Control.Monad.Except.IO: class Monad m => MonadError e (m :: Type -> Type) | m -> e
+ Control.Monad.Except.IO: handleError :: MonadError e m => (e -> m a) -> m a -> m a
+ Control.Monad.Except.IO: liftEither :: MonadError e m => Either e a -> m a
+ Control.Monad.Except.IO: mapError :: (MonadError e m, MonadError e' n) => (m (Either e a) -> n (Either e' b)) -> m a -> n b
+ Control.Monad.Except.IO: throwError :: MonadError e m => e -> m a
+ Control.Monad.Except.IO: tryError :: MonadError e m => m a -> m (Either e a)
+ Control.Monad.Except.IO: withError :: MonadError e m => (e -> e) -> m a -> m a

Files

README.md view
@@ -1,1 +1,33 @@ # `exceptiot`++Sometimes, it is nice to write code in `MonadError` to indicate that the code+can throw an exception.++```haskell+foo :: MonadError FooError m => Int -> m Char+```++We can call `foo` in `Either FooError` for a pure test, or a `ExceptT FooError+IO` if we are writing in some monad directly. However, sometimes you can't use+`ExceptT`. One possible reason is performance: `ExceptT` can add overhead.+Another reason is `MonadUnliftIO` - `ExceptT` cannot have an instance for this.++You don't want to *stop* using `MonadError`, but you also can't use `ExceptT`+anymore. What can you do?++```haskell+import Control.Monad.Except.IO++main :: IO ()+main = do+    eres <- runExceptIOT (foo 3)+    case eres of+        Left FooError ->+            putStrLn "got FooError"+        Right c ->+            putChar c+```++You can replace `ExceptT` with `ExceptIOT`, and all exception use will switch to+`IO` based exceptions instead of `Either`-based values. This allows you to use+`MonadUnliftIO` without fear.
changelog.md view
@@ -1,5 +1,11 @@ # exceptiot +## 0.0.1.1++* [#3](https://github.com/parsonsmatt/exceptiot/pull/3)+    * Add imports for `Control.Monad.Fix` and `Control.Monad`, allowing to build+      with newer `mtl`.+ ## 0.0.1.0  * [#1](https://github.com/parsonsmatt/exceptiot/pull/1)
exceptiot.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.0.+-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack  name:           exceptiot-version:        0.0.1.0+version:        0.0.1.1 synopsis:       ExceptT, but uses IO instead of Either description:    Please see the README on Github at <https://github.com/parsonsmatt/exceptiot#readme> category:       Control
src/Control/Monad/Except/Catch.hs view
@@ -11,9 +11,10 @@     ) where  import Control.Applicative+import Control.Monad import Control.Monad.Catch import Control.Monad.Error.Class hiding (modifyError)-import qualified Control.Monad.Except as Except+import Control.Monad.Fix import Control.Monad.IO.Unlift import Control.Monad.Reader import Control.Monad.State@@ -48,7 +49,7 @@ runExceptCatchT :: (Exception e, MonadCatch m) => ExceptCatchT e m a -> m (Either e a) runExceptCatchT = try . unsafeRunExceptCatchT --- | Like 'Except.modifyError', but it selects the 'ExceptCatchT' instance for 'IO'+-- | Like 'Control.Monad.Except.modifyError', but it selects the 'ExceptCatchT' instance for 'IO' -- exceptions instead of the 'ExceptT' instance with an 'Either' error. -- -- @since 0.1.0.0
src/Control/Monad/Except/IO.hs view
@@ -11,9 +11,11 @@     ) where  import Control.Applicative+import Control.Monad import Control.Monad.Catch hiding (catch, try) import Control.Monad.Error.Class hiding (modifyError) import qualified Control.Monad.Except as Except+import Control.Monad.Fix import Control.Monad.Reader import Control.Monad.State import Control.Monad.Writer