either-unwrap 1.0 → 1.1
raw patch · 2 files changed
+21/−2 lines, 2 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Data.Either.Unwrap: mapBoth :: (a -> c) -> (b -> d) -> Either a b -> Either c d
+ Data.Either.Unwrap: mapLeft :: (a -> c) -> Either a b -> Either c b
+ Data.Either.Unwrap: mapRight :: (b -> c) -> Either a b -> Either a c
- Data.Either.Unwrap: eitherM :: (Monad m) => Either a b -> (a -> m c) -> (b -> m c) -> m c
+ Data.Either.Unwrap: eitherM :: Monad m => Either a b -> (a -> m c) -> (b -> m c) -> m c
- Data.Either.Unwrap: unlessLeft :: (Monad m) => Either a b -> (b -> m ()) -> m ()
+ Data.Either.Unwrap: unlessLeft :: Monad m => Either a b -> (b -> m ()) -> m ()
- Data.Either.Unwrap: unlessRight :: (Monad m) => Either a b -> (a -> m ()) -> m ()
+ Data.Either.Unwrap: unlessRight :: Monad m => Either a b -> (a -> m ()) -> m ()
- Data.Either.Unwrap: whenLeft :: (Monad m) => Either a b -> (a -> m ()) -> m ()
+ Data.Either.Unwrap: whenLeft :: Monad m => Either a b -> (a -> m ()) -> m ()
- Data.Either.Unwrap: whenRight :: (Monad m) => Either a b -> (b -> m ()) -> m ()
+ Data.Either.Unwrap: whenRight :: Monad m => Either a b -> (b -> m ()) -> m ()
Files
- Data/Either/Unwrap.hs +19/−0
- either-unwrap.cabal +2/−2
Data/Either/Unwrap.hs view
@@ -17,6 +17,9 @@ , isRight , fromLeft , fromRight+ , mapBoth+ , mapLeft+ , mapRight , eitherM , whenLeft , whenRight@@ -48,6 +51,22 @@ fromRight :: Either a b -> b fromRight (Left _) = error "Either.Unwrap.fromRight: Argument takes form 'Left _'" -- yuck fromRight (Right x) = x++-- | The 'mapBoth' function takes two functions and applies the first if iff the value+-- takes the form 'Left _' and the second if the value takes the form 'Right _'.+mapBoth :: (a -> c) -> (b -> d) -> Either a b -> Either c d+mapBoth f _ (Left x) = Left (f x)+mapBoth _ f (Right x) = Right (f x)++-- | The 'mapLeft' function takes a function and applies it to an Either value+-- iff the value takes the form 'Left _'.+mapLeft :: (a -> c) -> Either a b -> Either c b+mapLeft = (`mapBoth` id)++-- | The 'mapLeft' function takes a function and applies it to an Either value+-- iff the value takes the form 'Left _'.+mapRight :: (b -> c) -> Either a b -> Either a c+mapRight = (id `mapBoth`) -- | The 'eitherM' function takes an 'Either' value and two functions which return monads. -- If the argument takes the form @Left _@ then the element within is passed to the first
either-unwrap.cabal view
@@ -1,6 +1,6 @@ Name: either-unwrap Description: Functions for probing and unwrapping values inside of Either.-Version: 1.0+Version: 1.1 Category: Data Cabal-Version: >= 1.2 License: BSD3@@ -12,7 +12,7 @@ Build-Type: Simple Library- Build-Depends: base >= 3+ Build-Depends: base >= 3 && < 5 Hs-Source-Dirs: . Exposed-Modules: Data.Either.Unwrap GHC-Options: -Wall