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

-- | Simplified error-handling
--   
--   The one-stop shop for all your error-handling needs! Just import
--   Control.Error.
--   
--   This library encourages an error-handling style that directly uses the
--   type system, rather than out-of-band exceptions.
@package errors
@version 2.3.0

-- | This module exports miscellaneous error-handling functions.
module Control.Error.Util

-- | Suppress the Left value of an Either
hush :: Either a b -> Maybe b

-- | Suppress the Left value of an ExceptT
hushT :: forall (m :: Type -> Type) a b. Monad m => ExceptT a m b -> MaybeT m b

-- | Tag the Nothing value of a Maybe
note :: a -> Maybe b -> Either a b

-- | Tag the Nothing value of a MaybeT
noteT :: forall (m :: Type -> Type) a b. Monad m => a -> MaybeT m b -> ExceptT a m b

-- | Lift a Maybe to the MaybeT monad
hoistMaybe :: forall (m :: Type -> Type) b. Monad m => Maybe b -> MaybeT m b

-- | Upgrade an Either to an ExceptT
hoistEither :: forall (m :: Type -> Type) e a. Monad m => Either e a -> ExceptT e m a

-- | Convert a Maybe value into the ExceptT monad
(??) :: forall (m :: Type -> Type) a e. Applicative m => Maybe a -> e -> ExceptT e m a

-- | Convert an applicative Maybe value into the ExceptT
--   monad
(!?) :: Applicative m => m (Maybe a) -> e -> ExceptT e m a

-- | Convert a Maybe value into the ExceptT monad
--   
--   Named version of (??) with arguments flipped
failWith :: forall (m :: Type -> Type) e a. Applicative m => e -> Maybe a -> ExceptT e m a

-- | Convert an applicative Maybe value into the ExceptT
--   monad
--   
--   Named version of (!?) with arguments flipped
failWithM :: Applicative m => e -> m (Maybe a) -> ExceptT e m a

-- | Case analysis for the Bool type.
--   
--   
--   bool a b c == if c then b else a
--   
bool :: a -> a -> Bool -> a

-- | An infix form of fromMaybe with arguments flipped.
(?:) :: Maybe a -> a -> a
infixr 0 ?:

-- | Case analysis for MaybeT
--   
--   Use the first argument if the MaybeT computation fails,
--   otherwise apply the function to the successful result.
maybeT :: Monad m => m b -> (a -> m b) -> MaybeT m a -> m b

-- | Analogous to Just and equivalent to return
just :: forall (m :: Type -> Type) a. Monad m => a -> MaybeT m a

-- | Analogous to Nothing and equivalent to mzero
nothing :: forall (m :: Type -> Type) a. Monad m => MaybeT m a

-- | Analogous to isJust, but for MaybeT
isJustT :: Monad m => MaybeT m a -> m Bool

-- | Analogous to isNothing, but for MaybeT
isNothingT :: Monad m => MaybeT m a -> m Bool

-- | Returns whether argument is a Left
isLeft :: Either a b -> Bool

-- | Returns whether argument is a Right
isRight :: Either a b -> Bool

-- | fmap specialized to Either, given a name symmetric to
--   fmapL
fmapR :: (a -> b) -> Either l a -> Either l b

-- | Run multiple Either computations and succeed if all of them
--   succeed
--   
--   mappends all successes or failures
newtype AllE e r
AllE :: Either e r -> AllE e r
[runAllE] :: AllE e r -> Either e r

-- | Run multiple Either computations and succeed if any of them
--   succeed
--   
--   mappends all successes or failures
newtype AnyE e r
AnyE :: Either e r -> AnyE e r
[runAnyE] :: AnyE e r -> Either e r

-- | Analogous to isLeft, but for ExceptT
isLeftT :: Monad m => ExceptT a m b -> m Bool

-- | Analogous to isRight, but for ExceptT
isRightT :: Monad m => ExceptT a m b -> m Bool

-- | fmap specialized to ExceptT, given a name symmetric to
--   fmapLT
fmapRT :: forall (m :: Type -> Type) a b l. Monad m => (a -> b) -> ExceptT l m a -> ExceptT l m b

-- | Fold an ExceptT by providing one continuation for each
--   constructor
exceptT :: Monad m => (a -> m c) -> (b -> m c) -> ExceptT a m b -> m c

-- | Transform the left and right value
bimapExceptT :: forall (m :: Type -> Type) e f a b. Functor m => (e -> f) -> (a -> b) -> ExceptT e m a -> ExceptT f m b

-- | Write a string to standard error
err :: Text -> IO ()

-- | Write a string with a newline to standard error
errLn :: Text -> IO ()

-- | Catch IOExceptions and convert them to the ExceptT monad
tryIO :: forall (m :: Type -> Type) a. MonadIO m => IO a -> ExceptT IOException m a

-- | Run a monad action which may throw an exception in the ExceptT
--   monad
handleExceptT :: (Exception e, Functor m, MonadCatch m) => (e -> x) -> m a -> ExceptT x m a

-- | Catch all exceptions, except for asynchronous exceptions found in
--   base and convert them to the ExceptT monad
syncIO :: forall (m :: Type -> Type) a. MonadIO m => IO a -> ExceptT SomeException m a
instance (GHC.Internal.Base.Monoid e, GHC.Internal.Base.Monoid r) => GHC.Internal.Base.Monoid (Control.Error.Util.AllE e r)
instance (GHC.Internal.Base.Monoid e, GHC.Internal.Base.Monoid r) => GHC.Internal.Base.Monoid (Control.Error.Util.AnyE e r)
instance (GHC.Internal.Base.Semigroup e, GHC.Internal.Base.Semigroup r) => GHC.Internal.Base.Semigroup (Control.Error.Util.AllE e r)
instance (GHC.Internal.Base.Semigroup e, GHC.Internal.Base.Semigroup r) => GHC.Internal.Base.Semigroup (Control.Error.Util.AnyE e r)

-- | This module extends the safe library's functions with
--   corresponding versions compatible with Either and
--   ExceptT, and also provides a few Maybe-compatible
--   functions missing from safe.
--   
--   I suffix the Either-compatible functions with Err and
--   prefix the ExceptT-compatible functions with try.
--   
--   Note that this library re-exports the Maybe compatible
--   functions from safe in the Control.Error module, so
--   they are not provided here.
--   
--   The 'Z'-suffixed functions generalize the Maybe
--   functions to also work with anything that implements MonadPlus,
--   including:
--   
--   
--   
- Lists
--   
- Most parsers
--   
- ExceptT (if the left value is a Monoid)
--   
module Control.Error.Safe

-- | An assertion that fails in the Maybe monad
assertMay :: Bool -> Maybe ()

-- | A fromRight that fails in the Maybe monad
rightMay :: Either e a -> Maybe a

-- | A tail that fails in the Either monad
tailErr :: e -> [a] -> Either e [a]

-- | An init that fails in the Either monad
initErr :: e -> [a] -> Either e [a]

-- | A head that fails in the Either monad
headErr :: e -> [a] -> Either e a

-- | A last that fails in the Either monad
lastErr :: e -> [a] -> Either e a

-- | A minimum that fails in the Either monad
minimumErr :: Ord a => e -> [a] -> Either e a

-- | A maximum that fails in the Either monad
maximumErr :: Ord a => e -> [a] -> Either e a

-- | A foldr1 that fails in the Either monad
foldr1Err :: e -> (a -> a -> a) -> [a] -> Either e a

-- | A foldl1 that fails in the Either monad
foldl1Err :: e -> (a -> a -> a) -> [a] -> Either e a

-- | A foldl1' that fails in the Either monad
foldl1Err' :: e -> (a -> a -> a) -> [a] -> Either e a

-- | A (!!) that fails in the Either monad
atErr :: e -> [a] -> Int -> Either e a

-- | A read that fails in the Either monad
readErr :: Read a => e -> String -> Either e a

-- | An assertion that fails in the Either monad
assertErr :: e -> Bool -> Either e ()

-- | A fromJust that fails in the Either monad
justErr :: e -> Maybe a -> Either e a

-- | A tail that fails in the ExceptT monad
tryTail :: forall (m :: Type -> Type) e a. Monad m => e -> [a] -> ExceptT e m [a]

-- | An init that fails in the ExceptT monad
tryInit :: forall (m :: Type -> Type) e a. Monad m => e -> [a] -> ExceptT e m [a]

-- | A head that fails in the ExceptT monad
tryHead :: forall (m :: Type -> Type) e a. Monad m => e -> [a] -> ExceptT e m a

-- | A last that fails in the ExceptT monad
tryLast :: forall (m :: Type -> Type) e a. Monad m => e -> [a] -> ExceptT e m a

-- | A minimum that fails in the ExceptT monad
tryMinimum :: forall (m :: Type -> Type) a e. (Monad m, Ord a) => e -> [a] -> ExceptT e m a

-- | A maximum that fails in the ExceptT monad
tryMaximum :: forall (m :: Type -> Type) a e. (Monad m, Ord a) => e -> [a] -> ExceptT e m a

-- | A foldr1 that fails in the ExceptT monad
tryFoldr1 :: forall (m :: Type -> Type) e a. Monad m => e -> (a -> a -> a) -> [a] -> ExceptT e m a

-- | A foldl1 that fails in the ExceptT monad
tryFoldl1 :: forall (m :: Type -> Type) e a. Monad m => e -> (a -> a -> a) -> [a] -> ExceptT e m a

-- | A foldl1' that fails in the ExceptT monad
tryFoldl1' :: forall (m :: Type -> Type) e a. Monad m => e -> (a -> a -> a) -> [a] -> ExceptT e m a

-- | A (!!) that fails in the ExceptT monad
tryAt :: forall (m :: Type -> Type) e a. Monad m => e -> [a] -> Int -> ExceptT e m a

-- | A read that fails in the ExceptT monad
tryRead :: forall (m :: Type -> Type) a e. (Monad m, Read a) => e -> String -> ExceptT e m a

-- | An assertion that fails in the ExceptT monad
tryAssert :: forall (m :: Type -> Type) e. Monad m => e -> Bool -> ExceptT e m ()

-- | A fromJust that fails in the ExceptT monad
tryJust :: forall (m :: Type -> Type) e a. Monad m => e -> Maybe a -> ExceptT e m a

-- | A fromRight that fails in the ExceptT monad
tryRight :: forall (m :: Type -> Type) e a. Monad m => Either e a -> ExceptT e m a

-- | A tail that fails using mzero
tailZ :: MonadPlus m => [a] -> m [a]

-- | An init that fails using mzero
initZ :: MonadPlus m => [a] -> m [a]

-- | A head that fails using mzero
headZ :: MonadPlus m => [a] -> m a

-- | A last that fails using mzero
lastZ :: MonadPlus m => [a] -> m a

-- | A minimum that fails using mzero
minimumZ :: (MonadPlus m, Ord a) => [a] -> m a

-- | A maximum that fails using mzero
maximumZ :: (MonadPlus m, Ord a) => [a] -> m a

-- | A foldr1 that fails using mzero
foldr1Z :: MonadPlus m => (a -> a -> a) -> [a] -> m a

-- | A foldl1 that fails using mzero
foldl1Z :: MonadPlus m => (a -> a -> a) -> [a] -> m a

-- | A foldl1' that fails using mzero
foldl1Z' :: MonadPlus m => (a -> a -> a) -> [a] -> m a

-- | A (!!) that fails using mzero
atZ :: MonadPlus m => [a] -> Int -> m a

-- | A read that fails using mzero
readZ :: (MonadPlus m, Read a) => String -> m a

-- | An assertion that fails using mzero
assertZ :: MonadPlus m => Bool -> m ()

-- | A fromJust that fails using mzero
justZ :: MonadPlus m => Maybe a -> m a

-- | A fromRight that fails using mzero
rightZ :: MonadPlus m => Either e a -> m a

-- | This module provides throwEither and catchEither for
--   Either. These two functions reside here because
--   throwEither and catchEither correspond to return
--   and (>>=) for the flipped Either monad:
--   EitherR. Additionally, this module defines handleE as
--   the flipped version of catchE for ExceptT.
--   
--   throwEither and catchEither improve upon
--   MonadError because:
--   
--   
--   
- catchEither is more general than catch and allows
--   you to change the left value's type
--   
- Both are Haskell98
--   
--   
--   More advanced users can use EitherR and ExceptRT to
--   program in an entirely symmetric "success monad" where exceptional
--   results are the norm and successful results terminate the computation.
--   This allows you to chain error-handlers using do notation and
--   pass around exceptional values of varying types until you can finally
--   recover from the error:
--   
--   
--   runExceptRT $ do
--       e2   <- ioExceptionHandler e1
--       bool <- arithmeticExceptionhandler e2
--       when bool $ lift $ putStrLn "DEBUG: Arithmetic handler did something"
--   
--   
--   If any of the above error handlers succeed, no other handlers
--   are tried.
--   
--   If you choose not to typefully distinguish between the error and
--   sucess monad, then use flipEither and flipET, which swap
--   the type variables without changing the type.
module Data.EitherR

-- | If "Either e r" is the error monad, then "EitherR r
--   e" is the corresponding success monad, where:
--   
--   
--   
- return is throwEither.
--   
- (>>=) is catchEither.
--   
- Successful results abort the computation
--   
newtype EitherR r e
EitherR :: Either e r -> EitherR r e
[runEitherR] :: EitherR r e -> Either e r

-- | Complete error handling, returning a result
succeed :: r -> EitherR r e

-- | throwEither in the error monad corresponds to return in
--   the success monad
throwEither :: e -> Either e r

-- | catchEither in the error monad corresponds to
--   (>>=) in the success monad
catchEither :: Either a r -> (a -> Either b r) -> Either b r

-- | catchEither with the arguments flipped
handleEither :: (a -> Either b r) -> Either a r -> Either b r

-- | Map a function over the Left value of an Either
fmapL :: (a -> b) -> Either a r -> Either b r

-- | Flip the type variables of Either
flipEither :: Either a b -> Either b a

-- | EitherR converted into a monad transformer
newtype ExceptRT r (m :: Type -> Type) e
ExceptRT :: ExceptT e m r -> ExceptRT r (m :: Type -> Type) e
[runExceptRT] :: ExceptRT r (m :: Type -> Type) e -> ExceptT e m r

-- | Complete error handling, returning a result
succeedT :: forall (m :: Type -> Type) r e. Monad m => r -> ExceptRT r m e

-- | catchE with the arguments flipped
handleE :: forall (m :: Type -> Type) a b r. Monad m => (a -> ExceptT b m r) -> ExceptT a m r -> ExceptT b m r

-- | Map a function over the Left value of an ExceptT
fmapLT :: forall (m :: Type -> Type) a b r. Functor m => (a -> b) -> ExceptT a m r -> ExceptT b m r

-- | Flip the type variables of an ExceptT
flipET :: forall (m :: Type -> Type) a b. Monad m => ExceptT a m b -> ExceptT b m a
instance GHC.Internal.Base.Monoid r => GHC.Internal.Base.Alternative (Data.EitherR.EitherR r)
instance (GHC.Internal.Base.Monad m, GHC.Internal.Base.Monoid r) => GHC.Internal.Base.Alternative (Data.EitherR.ExceptRT r m)
instance GHC.Internal.Base.Applicative (Data.EitherR.EitherR r)
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Applicative (Data.EitherR.ExceptRT r m)
instance GHC.Internal.Base.Functor (Data.EitherR.EitherR r)
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Functor (Data.EitherR.ExceptRT r m)
instance GHC.Internal.Base.Monad (Data.EitherR.EitherR r)
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Monad (Data.EitherR.ExceptRT r m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Data.EitherR.ExceptRT r m)
instance GHC.Internal.Base.Monoid r => GHC.Internal.Base.MonadPlus (Data.EitherR.EitherR r)
instance (GHC.Internal.Base.Monad m, GHC.Internal.Base.Monoid r) => GHC.Internal.Base.MonadPlus (Data.EitherR.ExceptRT r m)
instance Control.Monad.Trans.Class.MonadTrans (Data.EitherR.ExceptRT r)

-- | Use this module if you like to write simple scripts with
--   Text-based errors, but you prefer to use ExceptT to
--   handle errors rather than Control.Exception.
--   
--   
--   import Control.Error
--   
--   main = runScript $ do
--       str <- scriptIO getLine
--       n   <- tryRead "Read failed" str
--       scriptIO $ print (n + 1)
--   
module Control.Error.Script

-- | An IO action that can fail with a Text error message
type Script = ExceptT Text IO

-- | Runs the Script monad
--   
--   Prints the first error to stderr and exits with
--   exitFailure
runScript :: Script a -> IO a

-- | scriptIO resembles lift, except it catches all
--   exceptions and converts them to Text
--   
--   Note that scriptIO is compatible with the Script monad.
scriptIO :: forall (m :: Type -> Type) a. MonadIO m => IO a -> ExceptT Text m a

-- | Import this module in your code to access the entire library's
--   functionality:
--   
--   
--   import Control.Error
--   
--   
--   This module exports the entire library as well as useful exports from
--   other standard error-handling libraries:
--   
--   
--   
- Control.Error.Safe: Generalizes the safe library,
--   including Either, EitherT, and MonadPlus
--   variations on total functions
--   
- Control.Error.Script: Support for simple scripts that catch
--   all errors and transform them to Text
--   
- Control.Error.Util: Utility functions and conversions
--   between common error-handling types
--   
- Control.Monad.Trans.Except: The ExceptT monad
--   transformer
--   
- Control.Monad.Trans.Maybe: The MaybeT monad
--   transformer
--   
- Data.Either: Either utility functions
--   
- Data.EitherR: throw and catch functions, and their
--   corresponding "success" monads
--   
- Data.Maybe: Maybe utility functions
--   
- Safe: Total versions of partial Prelude functions
--   
--   
--   This module does not re-export partial functions from other libraries.
module Control.Error

-- | Signal an exception value e.
--   
--   
--   
- 
runExceptT (throwE e) = return
--   (Left e)

--   
- 
throwE e >>= m = throwE e

--   
throwE :: forall (m :: Type -> Type) e a. Monad m => e -> ExceptT e m a

-- | A monad transformer that adds exceptions to other monads.
--   
--   ExceptT constructs a monad parameterized over two things:
--   
--   
--   
- e - The exception type.
--   
- m - The inner monad.
--   
--   
--   The return function yields a computation that produces the
--   given value, while >>= sequences two subcomputations,
--   exiting on the first exception.
newtype ExceptT e (m :: Type -> Type) a
ExceptT :: m (Either e a) -> ExceptT e (m :: Type -> Type) a

-- | The inverse of ExceptT.
runExceptT :: ExceptT e m a -> m (Either e a)

-- | Map the unwrapped computation using the given function.
--   
--   
--   
- 
runExceptT (mapExceptT f m) = f
--   (runExceptT m)

--   
mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b

-- | Transform any exceptions thrown by the computation using the given
--   function.
withExceptT :: forall (m :: Type -> Type) e e' a. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a

-- | Handle an exception.
--   
--   
--   
- 
catchE (lift m) h = lift m

--   
- 
catchE (throwE e) h = h e

--   
catchE :: forall (m :: Type -> Type) e a e'. Monad m => ExceptT e m a -> (e -> ExceptT e' m a) -> ExceptT e' m a

-- | The parameterizable maybe monad, obtained by composing an arbitrary
--   monad with the Maybe monad.
--   
--   Computations are actions that may produce a value or exit.
--   
--   The return function yields a computation that produces that
--   value, while >>= sequences two subcomputations, exiting
--   if either computation does.
newtype MaybeT (m :: Type -> Type) a
MaybeT :: m (Maybe a) -> MaybeT (m :: Type -> Type) a
[runMaybeT] :: MaybeT (m :: Type -> Type) a -> m (Maybe a)

-- | Lift a callCC operation to the new monad.
liftCallCC :: CallCC m (Maybe a) (Maybe b) -> CallCC (MaybeT m) a b

-- | Lift a catchE operation to the new monad.
liftCatch :: Catch e m (Maybe a) -> Catch e (MaybeT m) a

-- | Lift a listen operation to the new monad.
liftListen :: Monad m => Listen w m (Maybe a) -> Listen w (MaybeT m) a

-- | Lift a pass operation to the new monad.
liftPass :: Monad m => Pass w m (Maybe a) -> Pass w (MaybeT m) a

-- | Transform the computation inside a MaybeT.
--   
--   
--   
- 
runMaybeT (mapMaybeT f m) = f (runMaybeT
--   m)

--   
mapMaybeT :: (m (Maybe a) -> n (Maybe b)) -> MaybeT m a -> MaybeT n b

-- | Case analysis for the Either type. If the value is
--   Left a, apply the first function to a; if it
--   is Right b, apply the second function to b.
--   
--   
Examples
--   
--   We create two values of type Either String
--   Int, one using the Left constructor and another
--   using the Right constructor. Then we apply "either" the
--   length function (if we have a String) or the "times-two"
--   function (if we have an Int):
--   
--   
--   >>> let s = Left "foo" :: Either String Int
--   
--   >>> let n = Right 3 :: Either String Int
--   
--   >>> either length (*2) s
--   3
--   
--   >>> either length (*2) n
--   6
--   
either :: (a -> c) -> (b -> c) -> Either a b -> c

-- | Extracts from a list of Either all the Left elements.
--   All the Left elements are extracted in order.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   >>> lefts list
--   ["foo","bar","baz"]
--   
lefts :: [Either a b] -> [a]

-- | Extracts from a list of Either all the Right elements.
--   All the Right elements are extracted in order.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   >>> rights list
--   [3,7]
--   
rights :: [Either a b] -> [b]

-- | Partitions a list of Either into two lists. All the Left
--   elements are extracted, in order, to the first component of the
--   output. Similarly the Right elements are extracted to the
--   second component of the output.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   >>> partitionEithers list
--   (["foo","bar","baz"],[3,7])
--   
--   
--   The pair returned by partitionEithers x should be the
--   same pair as (lefts x, rights x):
--   
--   
--   >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   >>> partitionEithers list == (lefts list, rights list)
--   True
--   
partitionEithers :: [Either a b] -> ([a], [b])

-- | The maybe function takes a default value, a function, and a
--   Maybe value. If the Maybe value is Nothing, the
--   function returns the default value. Otherwise, it applies the function
--   to the value inside the Just and returns the result.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> maybe False odd (Just 3)
--   True
--   
--   
--   
--   >>> maybe False odd Nothing
--   False
--   
--   
--   Read an integer from a string using readMaybe. If we succeed,
--   return twice the integer; that is, apply (*2) to it. If
--   instead we fail to parse an integer, return 0 by default:
--   
--   
--   >>> import GHC.Internal.Text.Read ( readMaybe )
--   
--   >>> maybe 0 (*2) (readMaybe "5")
--   10
--   
--   >>> maybe 0 (*2) (readMaybe "")
--   0
--   
--   
--   Apply show to a Maybe Int. If we have Just n,
--   we want to show the underlying Int n. But if we have
--   Nothing, we return the empty string instead of (for example)
--   "Nothing":
--   
--   
--   >>> maybe "" show (Just 5)
--   "5"
--   
--   >>> maybe "" show Nothing
--   ""
--   
maybe :: b -> (a -> b) -> Maybe a -> b

-- | The isJust function returns True iff its argument is of
--   the form Just _.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isJust (Just 3)
--   True
--   
--   
--   
--   >>> isJust (Just ())
--   True
--   
--   
--   
--   >>> isJust Nothing
--   False
--   
--   
--   Only the outer constructor is taken into consideration:
--   
--   
--   >>> isJust (Just Nothing)
--   True
--   
isJust :: Maybe a -> Bool

-- | The isNothing function returns True iff its argument is
--   Nothing.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isNothing (Just 3)
--   False
--   
--   
--   
--   >>> isNothing (Just ())
--   False
--   
--   
--   
--   >>> isNothing Nothing
--   True
--   
--   
--   Only the outer constructor is taken into consideration:
--   
--   
--   >>> isNothing (Just Nothing)
--   False
--   
isNothing :: Maybe a -> Bool

-- | The fromMaybe function takes a default value and a Maybe
--   value. If the Maybe is Nothing, it returns the default
--   value; otherwise, it returns the value contained in the Maybe.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> fromMaybe "" (Just "Hello, World!")
--   "Hello, World!"
--   
--   
--   
--   >>> fromMaybe "" Nothing
--   ""
--   
--   
--   Read an integer from a string using readMaybe. If we fail to
--   parse an integer, we want to return 0 by default:
--   
--   
--   >>> import GHC.Internal.Text.Read ( readMaybe )
--   
--   >>> fromMaybe 0 (readMaybe "5")
--   5
--   
--   >>> fromMaybe 0 (readMaybe "")
--   0
--   
fromMaybe :: a -> Maybe a -> a

-- | The maybeToList function returns an empty list when given
--   Nothing or a singleton list when given Just.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> maybeToList (Just 7)
--   [7]
--   
--   
--   
--   >>> maybeToList Nothing
--   []
--   
--   
--   One can use maybeToList to avoid pattern matching when combined
--   with a function that (safely) works on lists:
--   
--   
--   >>> import GHC.Internal.Text.Read ( readMaybe )
--   
--   >>> sum $ maybeToList (readMaybe "3")
--   3
--   
--   >>> sum $ maybeToList (readMaybe "")
--   0
--   
maybeToList :: Maybe a -> [a]

-- | The listToMaybe function returns Nothing on an empty
--   list or Just a where a is the first element
--   of the list.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> listToMaybe []
--   Nothing
--   
--   
--   
--   >>> listToMaybe [9]
--   Just 9
--   
--   
--   
--   >>> listToMaybe [1,2,3]
--   Just 1
--   
--   
--   Composing maybeToList with listToMaybe should be the
--   identity on singleton/empty lists:
--   
--   
--   >>> maybeToList $ listToMaybe [5]
--   [5]
--   
--   >>> maybeToList $ listToMaybe []
--   []
--   
--   
--   But not on lists with more than one element:
--   
--   
--   >>> maybeToList $ listToMaybe [1,2,3]
--   [1]
--   
listToMaybe :: [a] -> Maybe a

-- | The catMaybes function takes a list of Maybes and
--   returns a list of all the Just values.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> catMaybes [Just 1, Nothing, Just 3]
--   [1,3]
--   
--   
--   When constructing a list of Maybe values, catMaybes can
--   be used to return all of the "success" results (if the list is the
--   result of a map, then mapMaybe would be more
--   appropriate):
--   
--   
--   >>> import GHC.Internal.Text.Read ( readMaybe )
--   
--   >>> [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
--   [Just 1,Nothing,Just 3]
--   
--   >>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
--   [1,3]
--   
catMaybes :: [Maybe a] -> [a]

-- | The mapMaybe function is a version of map which can
--   throw out elements. In particular, the functional argument returns
--   something of type Maybe b. If this is Nothing,
--   no element is added on to the result list. If it is Just
--   b, then b is included in the result list.
--   
--   
Examples
--   
--   Using mapMaybe f x is a shortcut for
--   catMaybes $ map f x in most cases:
--   
--   
--   >>> import GHC.Internal.Text.Read ( readMaybe )
--   
--   >>> let readMaybeInt = readMaybe :: String -> Maybe Int
--   
--   >>> mapMaybe readMaybeInt ["1", "Foo", "3"]
--   [1,3]
--   
--   >>> catMaybes $ map readMaybeInt ["1", "Foo", "3"]
--   [1,3]
--   
--   
--   If we map the Just constructor, the entire list should be
--   returned:
--   
--   
--   >>> mapMaybe Just [1,2,3]
--   [1,2,3]
--   
mapMaybe :: (a -> Maybe b) -> [a] -> [b]
foldr1May :: (a -> a -> a) -> [a] -> Maybe a
minimumMay :: Ord a => [a] -> Maybe a
maximumMay :: Ord a => [a] -> Maybe a
findJustDef :: a -> (a -> Bool) -> [a] -> a

-- | New users are recommended to use minimumBound or
--   maximumBound instead.
minimumDef :: Ord a => a -> [a] -> a

-- | New users are recommended to use minimumBound or
--   maximumBound instead.
maximumDef :: Ord a => a -> [a] -> a
foldr1Def :: a -> (a -> a -> a) -> [a] -> a

-- | 
--   tailMay [] = Nothing
--   tailMay [1,3,4] = Just [3,4]
--   
tailMay :: [a] -> Maybe [a]

-- | 
--   tailDef [12] [] = [12]
--   tailDef [12] [1,3,4] = [3,4]
--   
tailDef :: [a] -> [a] -> [a]

-- | 
--   tailSafe [] = []
--   tailSafe [1,3,4] = [3,4]
--   
tailSafe :: [a] -> [a]
initMay :: [a] -> Maybe [a]
initDef :: [a] -> [a] -> [a]
initSafe :: [a] -> [a]
headMay :: [a] -> Maybe a
lastMay :: [a] -> Maybe a
headDef :: a -> [a] -> a
lastDef :: a -> [a] -> a
foldl1May' :: (a -> a -> a) -> [a] -> Maybe a

-- | An alternative name for fromMaybe, to fit the naming scheme of
--   this package. Generally using fromMaybe directly would be
--   considered better style.
fromJustDef :: a -> Maybe a -> a
atMay :: [a] -> Int -> Maybe a
atDef :: a -> [a] -> Int -> a
readMay :: Read a => String -> Maybe a
readDef :: Read a => a -> String -> a
lookupJustDef :: Eq a => b -> a -> [(a, b)] -> b
foldl1Def' :: a -> (a -> a -> a) -> [a] -> a
