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

-- | A compatibility layer for base
--   
--   Provides functions available in later versions of base to a
--   wider range of compilers, without requiring you to use CPP pragmas in
--   your code. See the README for what is covered. Also see the
--   changelog for recent changes.
--   
--   Note that base-compat does not add any orphan instances.
--   There is a separate package base-orphans for that.
@package base-compat
@version 0.8.2

module Text.Read.Compat

-- | Parsing of Strings, producing values.
--   
--   Derived instances of Read make the following assumptions, which
--   derived instances of Show obey:
--   
--   
--   
- If the constructor is defined to be an infix operator, then the
--   derived Read instance will parse only infix applications of the
--   constructor (not the prefix form).
--   
- Associativity is not used to reduce the occurrence of parentheses,
--   although precedence may be.
--   
- If the constructor is defined using record syntax, the derived
--   Read will parse only the record-syntax form, and furthermore,
--   the fields must be given in the same order as the original
--   declaration.
--   
- The derived Read instance allows arbitrary Haskell
--   whitespace between tokens of the input string. Extra parentheses are
--   also allowed.
--   
--   
--   For example, given the declarations
--   
--   
--   infixr 5 :^:
--   data Tree a =  Leaf a  |  Tree a :^: Tree a
--   
--   
--   the derived instance of Read in Haskell 2010 is equivalent to
--   
--   
--   instance (Read a) => Read (Tree a) where
--   
--           readsPrec d r =  readParen (d > app_prec)
--                            (\r -> [(Leaf m,t) |
--                                    ("Leaf",s) <- lex r,
--                                    (m,t) <- readsPrec (app_prec+1) s]) r
--   
--                         ++ readParen (d > up_prec)
--                            (\r -> [(u:^:v,w) |
--                                    (u,s) <- readsPrec (up_prec+1) r,
--                                    (":^:",t) <- lex s,
--                                    (v,w) <- readsPrec (up_prec+1) t]) r
--   
--             where app_prec = 10
--                   up_prec = 5
--   
--   
--   Note that right-associativity of :^: is unused.
--   
--   The derived instance in GHC is equivalent to
--   
--   
--   instance (Read a) => Read (Tree a) where
--   
--           readPrec = parens $ (prec app_prec $ do
--                                    Ident "Leaf" <- lexP
--                                    m <- step readPrec
--                                    return (Leaf m))
--   
--                        +++ (prec up_prec $ do
--                                    u <- step readPrec
--                                    Symbol ":^:" <- lexP
--                                    v <- step readPrec
--                                    return (u :^: v))
--   
--             where app_prec = 10
--                   up_prec = 5
--   
--           readListPrec = readListPrecDefault
--   
class Read a

-- | attempts to parse a value from the front of the string, returning a
--   list of (parsed value, remaining string) pairs. If there is no
--   successful parse, the returned list is empty.
--   
--   Derived instances of Read and Show satisfy the
--   following:
--   
--   
--   
- (x,"") is an element of (readsPrec d
--   (showsPrec d x "")).
--   
--   
--   That is, readsPrec parses the string produced by
--   showsPrec, and delivers the value that showsPrec started
--   with.
readsPrec :: Read a => Int -> ReadS a

-- | The method readList is provided to allow the programmer to give
--   a specialised way of parsing lists of values. For example, this is
--   used by the predefined Read instance of the Char type,
--   where values of type String should be are expected to use
--   double quotes, rather than square brackets.
readList :: Read a => ReadS [a]

-- | Proposed replacement for readsPrec using new-style parsers (GHC
--   only).
readPrec :: Read a => ReadPrec a

-- | Proposed replacement for readList using new-style parsers (GHC
--   only). The default definition uses readList. Instances that
--   define readPrec should also define readListPrec as
--   readListPrecDefault.
readListPrec :: Read a => ReadPrec [a]

-- | A parser for a type a, represented as a function that takes a
--   String and returns a list of possible parses as
--   (a,String) pairs.
--   
--   Note that this kind of backtracking parser is very inefficient;
--   reading a large structure may be quite slow (cf ReadP).
type ReadS a = String -> [(a, String)]

-- | equivalent to readsPrec with a precedence of 0.
reads :: Read a => ReadS a

-- | The read function reads input from a string, which must be
--   completely consumed by the input process.
read :: Read a => String -> a

-- | readParen True p parses what p parses,
--   but surrounded with parentheses.
--   
--   readParen False p parses what p
--   parses, but optionally surrounded with parentheses.
readParen :: Bool -> ReadS a -> ReadS a

-- | The lex function reads a single lexeme from the input,
--   discarding initial white space, and returning the characters that
--   constitute the lexeme. If the input string contains only white space,
--   lex returns a single successful `lexeme' consisting of the
--   empty string. (Thus lex "" = [("","")].) If there is
--   no legal lexeme at the beginning of the input string, lex fails
--   (i.e. returns []).
--   
--   This lexer is not completely faithful to the Haskell lexical syntax in
--   the following respects:
--   
--   
--   
- Qualified names are not handled properly
--   
- Octal and hexadecimal numerics are not recognized as a single
--   token
--   
- Comments are not treated properly
--   
lex :: ReadS String
data Lexeme :: *

-- | Character literal
Char :: Char -> Lexeme

-- | String literal, with escapes interpreted
String :: String -> Lexeme

-- | Punctuation or reserved symbol, e.g. (, ::
Punc :: String -> Lexeme

-- | Haskell identifier, e.g. foo, Baz
Ident :: String -> Lexeme

-- | Haskell symbol, e.g. >>, :%
Symbol :: String -> Lexeme

Number :: Number -> Lexeme
EOF :: Lexeme

-- | Parse a single lexeme
lexP :: ReadPrec Lexeme

-- | (parens p) parses "P", "(P0)", "((P0))", etc, where
--   p parses "P" in the current precedence context and parses
--   "P0" in precedence context zero
parens :: ReadPrec a -> ReadPrec a

-- | A possible replacement definition for the readList method (GHC
--   only). This is only needed for GHC, and even then only for Read
--   instances where readListPrec isn't defined as
--   readListPrecDefault.
readListDefault :: Read a => ReadS [a]

-- | A possible replacement definition for the readListPrec method,
--   defined using readPrec (GHC only).
readListPrecDefault :: Read a => ReadPrec [a]

-- | Parse a string using the Read instance. Succeeds if there is
--   exactly one valid result. A Left value indicates a parse error.
readEither :: Read a => String -> Either String a

-- | Parse a string using the Read instance. Succeeds if there is
--   exactly one valid result.
readMaybe :: Read a => String -> Maybe a

module System.Exit.Compat

-- | Write given error message to stderr and terminate with
--   exitFailure.
die :: String -> IO a

-- | Miscellaneous information about the system environment.
module System.Environment.Compat

-- | Computation getArgs returns a list of the program's command
--   line arguments (not including the program name).
getArgs :: IO [String]

-- | Computation getProgName returns the name of the program as it
--   was invoked.
--   
--   However, this is hard-to-impossible to implement on some non-Unix
--   OSes, so instead, for maximum portability, we just return the leafname
--   of the program as invoked. Even then there are some differences
--   between platforms: on Windows, for example, a program invoked as foo
--   is probably really FOO.EXE, and that is what
--   getProgName will return.
getProgName :: IO String

-- | Computation getEnv var returns the value of the
--   environment variable var. For the inverse, POSIX users can
--   use putEnv.
--   
--   This computation may fail with:
--   
--   
--   
- isDoesNotExistError if the environment variable does not
--   exist.
--   
getEnv :: String -> IO String

-- | Return the value of the environment variable var, or
--   Nothing if there is no such value.
--   
--   For POSIX users, this is equivalent to getEnv.
lookupEnv :: String -> IO (Maybe String)

-- | setEnv name value sets the specified environment variable to
--   value.
--   
--   On Windows setting an environment variable to the empty string
--   removes that environment variable from the environment. For the sake
--   of compatibility we adopt that behavior. In particular
--   
--   
--   setEnv name ""
--   
--   
--   has the same effect as
--   
--   
--   unsetEnv name
--   
--   
--   If you don't care about Windows support and want to set an environment
--   variable to the empty string use System.Posix.Env.setEnv from
--   the unix package instead.
--   
--   Throws IOException if name is the empty string or
--   contains an equals sign.
setEnv :: String -> String -> IO ()

-- | unSet name removes the specified environment variable from
--   the environment of the current process.
--   
--   Throws IOException if name is the empty string or
--   contains an equals sign.
unsetEnv :: String -> IO ()

-- | withArgs args act - while executing action
--   act, have getArgs return args.
withArgs :: [String] -> IO a -> IO a

-- | withProgName name act - while executing action
--   act, have getProgName return name.
withProgName :: String -> IO a -> IO a

-- | getEnvironment retrieves the entire environment as a list of
--   (key,value) pairs.
--   
--   If an environment entry does not contain an '=' character,
--   the key is the whole entry and the value is the
--   empty string.
getEnvironment :: IO [(String, String)]

module Prelude.Compat

module Numeric.Compat

-- | Show a signed RealFloat value using standard decimal notation
--   (e.g. 245000, 0.0015).
--   
--   This behaves as showFFloat, except that a decimal point is
--   always guaranteed, even if not needed.
showFFloatAlt :: RealFloat a => Maybe Int -> a -> ShowS

-- | Show a signed RealFloat value using standard decimal notation
--   for arguments whose absolute value lies between 0.1 and
--   9,999,999, and scientific notation otherwise.
--   
--   This behaves as showFFloat, except that a decimal point is
--   always guaranteed, even if not needed.
showGFloatAlt :: RealFloat a => Maybe Int -> a -> ShowS

module Foreign.Marshal.Utils.Compat

-- | Fill a given number of bytes in memory area with a byte value.
fillBytes :: Ptr a -> Word8 -> Int -> IO ()

module Foreign.Marshal.Array.Compat

-- | Like mallocArray, but allocated memory is filled with bytes of
--   value zero.
callocArray :: Storable a => Int -> IO (Ptr a)

-- | Like callocArray0, but allocated memory is filled with bytes of
--   value zero.
callocArray0 :: Storable a => Int -> IO (Ptr a)

module Foreign.Marshal.Alloc.Compat

-- | Like malloc but memory is filled with bytes of value zero.
calloc :: Storable a => IO (Ptr a)

-- | Llike mallocBytes but memory is filled with bytes of value
--   zero.
callocBytes :: Int -> IO (Ptr a)

module Foreign.Marshal.Compat

module Foreign.Compat

module Debug.Trace.Compat

-- | Like trace but returns the message instead of a third value.
traceId :: String -> String

-- | Like traceShow but returns the shown value instead of a third
--   value.
traceShowId :: Show a => a -> a

-- | Like trace but returning unit in an arbitrary monad. Allows for
--   convenient use in do-notation. Note that the application of
--   trace is not an action in the monad, as traceIO is in
--   the IO monad.
--   
--   
--   ... = do
--     x <- ...
--     traceM $ "x: " ++ show x
--     y <- ...
--     traceM $ "y: " ++ show y
--   
traceM :: Monad m => String -> m ()

-- | Like traceM, but uses show on the argument to convert it
--   to a String.
--   
--   
--   ... = do
--     x <- ...
--     traceMShow $ x
--     y <- ...
--     traceMShow $ x + y
--   
traceShowM :: (Show a, Monad m) => a -> m ()

module Data.Word.Compat

-- | Swap bytes in Word16.
byteSwap16 :: Word16 -> Word16

-- | Reverse order of bytes in Word32.
byteSwap32 :: Word32 -> Word32

-- | Reverse order of bytes in Word64.
byteSwap64 :: Word64 -> Word64

module Data.Version.Compat

-- | Construct tag-less Version
makeVersion :: [Int] -> Version

module Data.Monoid.Compat

-- | An infix synonym for mappend.
(<>) :: Monoid m => m -> m -> m

module Data.List.Compat

module Data.Functor.Compat

-- | The Functor class is used for types that can be mapped over.
--   Instances of Functor should satisfy the following laws:
--   
--   
--   fmap id  ==  id
--   fmap (f . g)  ==  fmap f . fmap g
--   
--   
--   The instances of Functor for lists, Maybe and IO
--   satisfy these laws.
class Functor (f :: * -> *)
fmap :: Functor f => (a -> b) -> f a -> f b

-- | Replace all locations in the input with the same value. The default
--   definition is fmap . const, but this may be
--   overridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a

-- | Flipped version of <$.
--   
--   
Examples
--   
--   Replace the contents of a Maybe Int with a
--   constant String:
--   
--   
--   >>> Nothing $> "foo"
--   Nothing
--   
--   >>> Just 90210 $> "foo"
--   Just "foo"
--   
--   
--   Replace the contents of an Either Int
--   Int with a constant String, resulting in an
--   Either Int String:
--   
--   
--   >>> Left 8675309 $> "foo"
--   Left 8675309
--   
--   >>> Right 8675309 $> "foo"
--   Right "foo"
--   
--   
--   Replace each element of a list with a constant String:
--   
--   
--   >>> [1,2,3] $> "foo"
--   ["foo","foo","foo"]
--   
--   
--   Replace the second element of a pair with a constant String:
--   
--   
--   >>> (1,2) $> "foo"
--   (1,"foo")
--   
($>) :: Functor f => f a -> b -> f b

-- | void value discards or ignores the result of
--   evaluation, such as the return value of an IO action.
--   
--   
Examples
--   
--   Replace the contents of a Maybe Int with
--   unit:
--   
--   
--   >>> void Nothing
--   Nothing
--   
--   >>> void (Just 3)
--   Just ()
--   
--   
--   Replace the contents of an Either Int
--   Int with unit, resulting in an Either
--   Int '()':
--   
--   
--   >>> void (Left 8675309)
--   Left 8675309
--   
--   >>> void (Right 8675309)
--   Right ()
--   
--   
--   Replace every element of a list with unit:
--   
--   
--   >>> void [1,2,3]
--   [(),(),()]
--   
--   
--   Replace the second element of a pair with unit:
--   
--   
--   >>> void (1,2)
--   (1,())
--   
--   
--   Discard the result of an IO action:
--   
--   
--   >>> mapM print [1,2]
--   1
--   2
--   [(),()]
--   
--   >>> void $ mapM print [1,2]
--   1
--   2
--   
void :: Functor f => f a -> f ()

module Data.Function.Compat

-- | & is a reverse application operator. This provides
--   notational convenience. Its precedence is one higher than that of the
--   forward application operator $, which allows & to be
--   nested in $.
(&) :: a -> (a -> b) -> b

module Data.Foldable.Compat

module Data.Either.Compat

-- | Return True if the given value is a Left-value,
--   False otherwise.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isLeft (Left "foo")
--   True
--   
--   >>> isLeft (Right 3)
--   False
--   
--   
--   Assuming a Left value signifies some sort of error, we can use
--   isLeft to write a very simple error-reporting function that
--   does absolutely nothing in the case of success, and outputs "ERROR" if
--   any error occurred.
--   
--   This example shows how isLeft might be used to avoid pattern
--   matching when one does not care about the value contained in the
--   constructor:
--   
--   
--   >>> import Control.Monad ( when )
--   
--   >>> let report e = when (isLeft e) $ putStrLn "ERROR"
--   
--   >>> report (Right 1)
--   
--   >>> report (Left "parse error")
--   ERROR
--   
isLeft :: Either a b -> Bool

-- | Return True if the given value is a Right-value,
--   False otherwise.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> isRight (Left "foo")
--   False
--   
--   >>> isRight (Right 3)
--   True
--   
--   
--   Assuming a Left value signifies some sort of error, we can use
--   isRight to write a very simple reporting function that only
--   outputs "SUCCESS" when a computation has succeeded.
--   
--   This example shows how isRight might be used to avoid pattern
--   matching when one does not care about the value contained in the
--   constructor:
--   
--   
--   >>> import Control.Monad ( when )
--   
--   >>> let report e = when (isRight e) $ putStrLn "SUCCESS"
--   
--   >>> report (Left "parse error")
--   
--   >>> report (Right 1)
--   SUCCESS
--   
isRight :: Either a b -> Bool

module Data.Bool.Compat

-- | Case analysis for the Bool type. bool x y p
--   evaluates to x when p is False, and evaluates
--   to y when p is True.
--   
--   This is equivalent to if p then y else x; that is, one can
--   think of it as an if-then-else construct with its arguments reordered.
--   
--   
Examples
--   
--   Basic usage:
--   
--   
--   >>> bool "foo" "bar" True
--   "bar"
--   
--   >>> bool "foo" "bar" False
--   "foo"
--   
--   
--   Confirm that bool x y p and if p then y else
--   x are equivalent:
--   
--   
--   >>> let p = True; x = "bar"; y = "foo"
--   
--   >>> bool x y p == if p then y else x
--   True
--   
--   >>> let p = False
--   
--   >>> bool x y p == if p then y else x
--   True
--   
bool :: a -> a -> Bool -> a

module Data.Bits.Compat

-- | Default implementation for bit.
--   
--   Note that: bitDefault i = 1 shiftL i
bitDefault :: (Bits a, Num a) => Int -> a

-- | Default implementation for testBit.
--   
--   Note that: testBitDefault x i = (x .&. bit i) /= 0
testBitDefault :: (Bits a, Num a) => a -> Int -> Bool

-- | Default implementation for popCount.
--   
--   This implementation is intentionally naive. Instances are expected to
--   provide an optimized implementation for their size.
popCountDefault :: (Bits a, Num a) => a -> Int

-- | Attempt to convert an Integral type a to an
--   Integral type b using the size of the types as
--   measured by Bits methods.
--   
--   A simpler version of this function is:
--   
--   
--   toIntegral :: (Integral a, Integral b) => a -> Maybe b
--   toIntegral x
--     | toInteger x == y = Just (fromInteger y)
--     | otherwise        = Nothing
--     where
--       y = toInteger x
--   
--   
--   This version requires going through Integer, which can be
--   inefficient. However, toIntegralSized is optimized to allow
--   GHC to statically determine the relative type sizes (as measured by
--   bitSizeMaybe and isSigned) and avoid going through
--   Integer for many types. (The implementation uses
--   fromIntegral, which is itself optimized with rules for
--   base types but may go through Integer for some type
--   pairs.)
toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b

module Control.Monad.Compat

-- | The Monad class defines the basic operations over a
--   monad, a concept from a branch of mathematics known as
--   category theory. From the perspective of a Haskell programmer,
--   however, it is best to think of a monad as an abstract datatype
--   of actions. Haskell's do expressions provide a convenient
--   syntax for writing monadic expressions.
--   
--   Instances of Monad should satisfy the following laws:
--   
--   
--   
- 
return a >>= k = k a

--   
- 
m >>= return = m

--   
- 
m >>= (x -> k x >>= h) = (m
--   >>= k) >>= h

--   
--   
--   Furthermore, the Monad and Applicative operations should
--   relate as follows:
--   
--   
--   
- 
pure = return

--   
- 
(<*>) = ap

--   
--   
--   The above laws imply:
--   
--   
--   
- 
fmap f xs = xs >>= return .
--   f

--   
- 
(>>) = (*>)

--   
--   
--   and that pure and (<*>) satisfy the applicative
--   functor laws.
--   
--   The instances of Monad for lists, Maybe and IO
--   defined in the Prelude satisfy these laws.
class Applicative m => Monad (m :: * -> *)

-- | Sequentially compose two actions, passing any value produced by the
--   first as an argument to the second.
(>>=) :: Monad m => m a -> (a -> m b) -> m b

-- | Sequentially compose two actions, discarding any value produced by the
--   first, like sequencing operators (such as the semicolon) in imperative
--   languages.
(>>) :: Monad m => m a -> m b -> m b

-- | Inject a value into the monadic type.
return :: Monad m => a -> m a

-- | Fail with a message. This operation is not part of the mathematical
--   definition of a monad, but is invoked on pattern-match failure in a
--   do expression.
fail :: Monad m => String -> m a

-- | Monads that also support choice and failure.
class (Alternative m, Monad m) => MonadPlus (m :: * -> *)

-- | the identity of mplus. It should also satisfy the equations
--   
--   
--   mzero >>= f  =  mzero
--   v >> mzero   =  mzero
--   
mzero :: MonadPlus m => m a

-- | an associative operation
mplus :: MonadPlus m => m a -> m a -> m a

module Control.Concurrent.MVar.Compat

-- | Like withMVar, but the IO action in the second
--   argument is executed with asynchronous exceptions masked.
withMVarMasked :: MVar a -> (a -> IO b) -> IO b
