packages feed

transformers-either 0.1.2 → 0.1.3

raw patch · 2 files changed

+55/−40 lines, 2 filesdep ~textdep ~transformers

Dependency ranges changed: text, transformers

Files

src/Control/Monad/Trans/Either.hs view
@@ -44,22 +44,26 @@    , bracketEitherT   , bracketExceptionT++  , hushM+  , onLeft+  , onNothing   ) where  import           Control.Exception (Exception, IOException, SomeException) import qualified Control.Exception as Exception-import           Control.Monad (Monad(..), (=<<))+import           Control.Monad (Monad (..), (=<<)) import           Control.Monad.Catch (Handler (..), MonadCatch, MonadMask, catchAll, mask, throwM) import qualified Control.Monad.Catch as Catch import           Control.Monad.IO.Class (MonadIO, liftIO) import           Control.Monad.Trans.Class (lift)-import           Control.Monad.Trans.Except (ExceptT(..))+import           Control.Monad.Trans.Except (ExceptT (..)) -import           Data.Maybe (Maybe, maybe)-import           Data.Either (Either(..), either)+import           Data.Either (Either (..), either) import           Data.Foldable (Foldable, foldr)-import           Data.Function (($), (.), const, id, flip)-import           Data.Functor (Functor(..))+import           Data.Function (const, flip, id, ($), (.))+import           Data.Functor (Functor (..))+import           Data.Maybe (Maybe (..), maybe)  import           System.IO (IO) @@ -302,3 +306,21 @@         z <- f a'         return $ either id (const b) z {-# INLINE bracketF #-}++-- | Convert an Either to a Maybe and execute the supplied handler+-- in the Left case.+hushM :: Monad m => Either e a -> (e -> m ()) -> m (Maybe a)+hushM r f = case r of+  Right a -> return (Just a)+  Left e -> f e >> return Nothing+{-# INLINE hushM #-}++-- | Handle the Left constructor in returned Either.+onLeft :: forall e x m a. Monad m => (e -> ExceptT x m a) -> EitherT x m (Either e a) -> EitherT x m a+onLeft h f = f >>= either h return+{-# INLINE onLeft #-}++-- | Handle the Nothing constructor in returned Maybe.+onNothing :: forall x m a. Monad m => EitherT x m a -> EitherT x m (Maybe a) -> EitherT x m a+onNothing h f = f >>= maybe h return+{-# INLINE onNothing #-}
transformers-either.cabal view
@@ -1,46 +1,39 @@-cabal-version:         3.0-name:                  transformers-either-version:               0.1.2-license:               BSD-3-Clause-license-file:          LICENSE-author:                Tim McGilchrist <timmcgil@gmail.com>-maintainer:            Tim McGilchrist <timmcgil@gmail.com>-copyright:             (c) 2017 Tim McGilchrist-synopsis:              An Either monad transformer-category:              System-build-type:            Simple-tested-with:           GHC == 8.10.5-                     , GHC == 8.8.4-                     , GHC == 8.6.5-                     , GHC == 8.4.4-                     , GHC == 8.2.2-                     , GHC == 8.0.2+cabal-version: 3.0+name:          transformers-either+version:       0.1.3+license:       BSD-3-Clause+license-file:  LICENSE+author:        Tim McGilchrist <timmcgil@gmail.com>+maintainer:    Tim McGilchrist <timmcgil@gmail.com>+copyright:     (c) 2023 Tim McGilchrist+synopsis:      An Either monad transformer+category:      System+build-type:    Simple+tested-with:+  GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.5  description:-            Drop in alternative to ExceptT.+  Drop in alternative to ExceptT.+  Uses a pattern synonym to maintain compatibility with the old EitherT types+  but is actually ExceptT under the covers. -            Uses a pattern synonym to maintain compatibility with the old EitherT types-            but is actually ExceptT under the covers. homepage:      http://github.com/tmcgilchrist/transformers-either/ bug-reports:   http://github.com/tmcgilchrist/transformers-either/issues+ source-repository head-  type: git+  type:     git   location: https://github.com/tmcgilchrist/transformers-either.git  library   build-depends:-                       base                            >= 4.8        && < 5-                     , text                            == 1.2.*-                     , exceptions                      >= 0.6        && < 0.11-                     , transformers                    >= 0.4        && < 0.6--  ghc-options:-                       -Wall--  default-language:   Haskell98-  hs-source-dirs:-                       src+    , base          >=4.8 && <5+    , exceptions    >=0.6 && <0.11+    , text          ^>=1.2+    , transformers  >=0.4 && <0.7 +  ghc-options:      -Wall+  default-language: Haskell98+  hs-source-dirs:   src   exposed-modules:-                       Control.Monad.Trans.Either-                       Control.Monad.Trans.Either.Exit+    Control.Monad.Trans.Either+    Control.Monad.Trans.Either.Exit