failure 0.1.0.1 → 0.1.1
raw patch · 2 files changed
+14/−5 lines, 2 filesdep +transformersPVP ok
version bump matches the API change (PVP)
Dependencies added: transformers
API changes (from Hackage documentation)
+ Control.Failure: instance (MonadTrans t, Failure e m, Monad (t m)) => Failure e (t m)
+ Control.Failure: instance Failure e (Either e)
Files
- Control/Failure.hs +11/−3
- failure.cabal +3/−2
Control/Failure.hs view
@@ -21,8 +21,10 @@ ) where import Prelude hiding (catch)-import Control.Exception (throw, catch, Exception, SomeException (..))+import Control.Exception (throwIO, catch, Exception, SomeException (..)) import Data.Typeable (Typeable)+import Control.Monad.Trans.Error ()+import Control.Monad.Trans.Class (MonadTrans (lift)) class Monad f => Failure e f where failure :: e -> f v@@ -35,7 +37,7 @@ wrapFailure :: (forall eIn. Exception eIn => eIn -> e) -> f a -> f a instance Exception e => WrapFailure e IO where wrapFailure f m =- m `catch` \e@SomeException{} -> throw (f e)+ m `catch` \e@SomeException{} -> throwIO (f e) class Try f where type Error f@@ -58,9 +60,15 @@ instance Failure e Maybe where failure _ = Nothing instance Failure e [] where failure _ = []+instance Failure e (Either e) where failure = Left instance Exception e => Failure e IO where- failure = Control.Exception.throw+ failure = throwIO++-- | Instance for all monad transformers, simply lift the @failure@ into the+-- base monad.+instance (MonadTrans t, Failure e m, Monad (t m)) => Failure e (t m) where+ failure = lift . failure -- not a monad or applicative instance Failure e (Either e) where failure = Left
failure.cabal view
@@ -1,5 +1,5 @@ name: failure-version: 0.1.0.1+version: 0.1.1 Cabal-Version: >= 1.6 build-type: Simple license: BSD3@@ -13,7 +13,8 @@ Library buildable: True- build-depends: base >= 4 && < 5+ build-depends: base >= 4 && < 5+ , transformers >= 0.2 && < 0.3 ghc-options: -Wall exposed-modules: