either 4.4.1.1 → 4.5
raw patch · 6 files changed
+133/−10 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.Either.Validation: instance (GHC.Classes.Eq e, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Either.Validation.Validation e a)
- Data.Either.Validation: instance (GHC.Classes.Ord e, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.Either.Validation.Validation e a)
- Data.Either.Validation: instance (GHC.Show.Show e, GHC.Show.Show a) => GHC.Show.Show (Data.Either.Validation.Validation e a)
+ Control.Monad.Trans.Either: firstEitherT :: Functor m => (e -> f) -> EitherT e m a -> EitherT f m a
+ Control.Monad.Trans.Either: instance Control.Monad.Morph.MMonad (Control.Monad.Trans.Either.EitherT e)
+ Data.Either.Validation: instance (GHC.Classes.Eq a, GHC.Classes.Eq e) => GHC.Classes.Eq (Data.Either.Validation.Validation e a)
+ Data.Either.Validation: instance (GHC.Classes.Ord a, GHC.Classes.Ord e) => GHC.Classes.Ord (Data.Either.Validation.Validation e a)
+ Data.Either.Validation: instance (GHC.Show.Show a, GHC.Show.Show e) => GHC.Show.Show (Data.Either.Validation.Validation e a)
Files
- .gitignore +2/−0
- .travis.yml +98/−2
- CHANGELOG.markdown +6/−0
- either.cabal +3/−3
- src/Control/Monad/Trans/Either.hs +21/−5
- src/Data/Either/Combinators.hs +3/−0
.gitignore view
@@ -11,3 +11,5 @@ *.hi *~ *#+.cabal-sandbox/+cabal.sandbox.config
.travis.yml view
@@ -1,8 +1,104 @@-language: haskell+# This file has been generated -- see https://github.com/hvr/multi-ghc-travis+language: c+sudo: false++cache:+ directories:+ - $HOME/.cabsnap+ - $HOME/.cabal/packages++before_cache:+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar++matrix:+ include:+ - env: CABALVER=1.18 GHCVER=7.4.2+ compiler: ": #GHC 7.4.2"+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.4.2], sources: [hvr-ghc]}}+ - env: CABALVER=1.18 GHCVER=7.6.3+ compiler: ": #GHC 7.6.3"+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.6.3], sources: [hvr-ghc]}}+ - env: CABALVER=1.18 GHCVER=7.8.4+ compiler: ": #GHC 7.8.4"+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}+ - env: CABALVER=1.22 GHCVER=7.10.3+ compiler: ": #GHC 7.10.3"+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}}+ - env: CABALVER=1.24 GHCVER=8.0.2+ compiler: ": #GHC 8.0.2"+ addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2], sources: [hvr-ghc]}}+ - env: CABALVER=2.0 GHCVER=8.2.1+ compiler: ": #GHC 8.2.1"+ addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.1], sources: [hvr-ghc]}}+ - env: CABALVER=head GHCVER=head+ compiler: ": #GHC head"+ addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}++ allow_failures:+ - env: CABALVER=head GHCVER=head++before_install:+ - unset CC+ - export PATH=$HOME/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH++install:+ - cabal --version+ - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"+ - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];+ then+ zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >+ $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;+ fi+ - travis_retry cabal update -v+ - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config+ - cabal install --only-dependencies --dry -v > installplan.txt+ - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt++# check whether current requested install-plan matches cached package-db snapshot+ - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;+ then+ echo "cabal build-cache HIT";+ rm -rfv .ghc;+ cp -a $HOME/.cabsnap/ghc $HOME/.ghc;+ cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;+ else+ echo "cabal build-cache MISS";+ rm -rf $HOME/.cabsnap;+ mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;+ cabal install -j --only-dependencies;+ fi++# snapshot package-db on cache miss+ - if [ ! -d $HOME/.cabsnap ];+ then+ echo "snapshotting package-db to build-cache";+ mkdir $HOME/.cabsnap;+ cp -a $HOME/.ghc $HOME/.cabsnap/ghc;+ cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;+ fi++# Here starts the actual work to be performed for the package under test;+# any command which exits with a non-zero exit code causes the build to fail.+script:+ - cabal configure -v2 # -v2 provides useful information for debugging+ - cabal build # this builds all libraries and executables (including tests/benchmarks)+ - cabal sdist # tests that a source-distribution can be generated+ - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ;+ cd dist/;+ if [ -f "$SRC_TGZ" ]; then+ cabal install "$SRC_TGZ";+ else+ echo "expected '$SRC_TGZ' not found";+ exit 1;+ fi+ notifications: irc: channels: - "irc.freenode.org#haskell-lens" skip_join: true template:- - "\x0313either\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}"+ - "\x0313either\x0f/\x0306%{branch}\x0f \x0314%{commit}\x0f %{message} \x0302\x1f%{build_url}\x0f"++# EOF
CHANGELOG.markdown view
@@ -1,3 +1,9 @@+4.5+----+* Add `MMonad` instance for `EitherT`+* Deprecate `Control.Monad.Trans.Either` in favor of `Control.Monad.Trans.Except`+* Add `firstEitherT`+ 4.4.1.1 ------- * Fixed building on newer GHCs. (type synonyms require explicit foralls for unused variables these days)
either.cabal view
@@ -1,6 +1,6 @@ name: either category: Control, Monads-version: 4.4.1.1+version: 4.5 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -32,9 +32,9 @@ exceptions >= 0.5 && < 0.9, free >= 4.9 && < 5, monad-control >= 0.3.2 && < 1.1,- MonadRandom >= 0.1 && < 0.5,+ MonadRandom >= 0.1 && < 0.6, mtl >= 2.0 && < 2.3,- mmorph >= 1.0.0 && < 1.1,+ mmorph >= 1.0.0 && < 1.2, profunctors >= 4 && < 6, semigroups >= 0.8.3.1 && < 1, semigroupoids >= 4 && < 6,
src/Control/Monad/Trans/Either.hs view
@@ -1,8 +1,4 @@ {-# LANGUAGE CPP #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif- {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-}@@ -23,6 +19,7 @@ ----------------------------------------------------------------------------- module Control.Monad.Trans.Either+{-# DEPRECATED "Use \"Control.Monad.Trans.Except\" from transformers or transformers-compat instead." #-} ( EitherT(..) , eitherT , bimapEitherT@@ -33,6 +30,7 @@ , left , right , swapEitherT+ , firstEitherT ) where import Control.Applicative@@ -50,13 +48,17 @@ import Control.Monad.Trans.Control (MonadBaseControl(..), MonadTransControl(..), defaultLiftBaseWith, defaultRestoreM) import Control.Monad.Writer.Class import Control.Monad.Random (MonadRandom,getRandom,getRandoms,getRandomR,getRandomRs)-import Control.Monad.Morph (MFunctor, hoist)+import Control.Monad.Morph (MFunctor(..), MMonad(..)) import Data.Either.Combinators ( swapEither )+#if __GLASGOW_HASKELL__ < 710 import Data.Foldable+#endif import Data.Function (on) import Data.Functor.Bind import Data.Functor.Plus+#if __GLASGOW_HASKELL__ < 710 import Data.Traversable+#endif import Data.Semigroup -- | 'EitherT' is a version of 'Control.Monad.Trans.Error.ErrorT' that does not@@ -98,6 +100,15 @@ hoist f = EitherT . f . runEitherT {-# INLINE hoist #-} +instance MMonad (EitherT e) where+ embed f m = EitherT $ do+ x <- runEitherT . f . runEitherT $ m+ return $ case x of+ Left e -> Left e+ Right (Left e) -> Left e+ Right (Right a) -> Right a+ {-# INLINE embed #-}+ -- | Given a pair of actions, one to perform in case of failure, and one to perform -- in case of success, run an 'EitherT' and get back a monadic result. eitherT :: Monad m => (a -> m c) -> (b -> m c) -> EitherT a m b -> m c@@ -122,6 +133,11 @@ h (Left e) = Left (f e) h (Right a) = Right (g a) {-# INLINE bimapEitherT #-}++-- | Map over failure+firstEitherT :: Functor m => (e -> f) -> EitherT e m a -> EitherT f m a+firstEitherT f = bimapEitherT f id+{-# INLINE firstEitherT #-} -- | Map the unwrapped computation using the given function. --
src/Data/Either/Combinators.hs view
@@ -1,3 +1,4 @@+{-# language CPP #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Either.Combinators@@ -36,7 +37,9 @@ , swapEither ) where +#if __GLASGOW_HASKELL__ < 710 import Control.Applicative+#endif import Control.Monad.Error.Class ( MonadError(throwError) ) -- ---------------------------------------------------------------------------