-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Functions for probing and unwrapping values inside of Either.
--   
--   Functions for probing and unwrapping values inside of Either.
@package either-unwrap
@version 1.1


-- | Functions for probing and unwrapping values inside of Either.
module Data.Either.Unwrap

-- | The <a>isLeft</a> function returns <a>True</a> iff its argument is of
--   the form <tt>Left _</tt>.
isLeft :: Either a b -> Bool

-- | The <a>isRight</a> function returns <a>True</a> iff its argument is of
--   the form <tt>Right _</tt>.
isRight :: Either a b -> Bool

-- | The <a>fromLeft</a> function extracts the element out of a <a>Left</a>
--   and throws an error if its argument take the form <tt>Right _</tt>.
fromLeft :: Either a b -> a

-- | The <a>fromRight</a> function extracts the element out of a
--   <a>Right</a> and throws an error if its argument take the form
--   <tt>Left _</tt>.
fromRight :: Either a b -> b

-- | The <a>mapBoth</a> 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

-- | The <a>mapLeft</a> 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

-- | The <a>mapLeft</a> 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

-- | The <a>eitherM</a> function takes an <a>Either</a> value and two
--   functions which return monads. If the argument takes the form <tt>Left
--   _</tt> then the element within is passed to the first function,
--   otherwise the element within is passed to the second function.
eitherM :: Monad m => Either a b -> (a -> m c) -> (b -> m c) -> m c

-- | The <a>whenLeft</a> function takes an <a>Either</a> value and a
--   function which returns a monad. The monad is only executed when the
--   given argument takes the form <tt>Left _</tt>, otherwise it does
--   nothing.
whenLeft :: Monad m => Either a b -> (a -> m ()) -> m ()

-- | The <a>whenLeft</a> function takes an <a>Either</a> value and a
--   function which returns a monad. The monad is only executed when the
--   given argument takes the form <tt>Right _</tt>, otherwise it does
--   nothing.
whenRight :: Monad m => Either a b -> (b -> m ()) -> m ()

-- | A synonym of <a>whenRight</a>.
unlessLeft :: Monad m => Either a b -> (b -> m ()) -> m ()

-- | A synonym of <a>whenLeft</a>.
unlessRight :: Monad m => Either a b -> (a -> m ()) -> m ()
