-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A compatibility layer for base
--
-- Ban CPP from your code. See the README for what is covered:
-- https://github.com/sol/base-compat#readme
@package base-compat
@version 0.5.0
module Text.Read.Compat
-- | Parsing of Strings, producing values.
--
-- Minimal complete definition: readsPrec (or, for GHC only,
-- readPrec)
--
-- 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 98 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
readsPrec :: Read a => Int -> ReadS a
readList :: Read a => ReadS [a]
readPrec :: Read a => ReadPrec a
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
-- | Haskell lexemes.
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
-- | Defines the exit codes that a program can return.
data ExitCode :: *
-- | indicates successful termination;
ExitSuccess :: ExitCode
-- | indicates program failure with an exit code. The exact interpretation
-- of the code is operating-system dependent. In particular, some values
-- may be prohibited (e.g. 0 on a POSIX-compliant system).
ExitFailure :: Int -> ExitCode
-- | Computation exitWith code throws ExitCode
-- code. Normally this terminates the program, returning
-- code to the program's caller.
--
-- On program termination, the standard Handles stdout
-- and stderr are flushed automatically; any other buffered
-- Handles need to be flushed manually, otherwise the buffered
-- data will be discarded.
--
-- A program that fails in any other way is treated as if it had called
-- exitFailure. A program that terminates successfully without
-- calling exitWith explicitly is treated as it it had called
-- exitWith ExitSuccess.
--
-- As an ExitCode is not an IOError, exitWith
-- bypasses the error handling in the IO monad and cannot be
-- intercepted by catch from the Prelude. However it is a
-- SomeException, and can be caught using the functions of
-- Control.Exception. This means that cleanup computations added
-- with bracket (from Control.Exception) are also executed
-- properly on exitWith.
--
-- Note: in GHC, exitWith should be called from the main program
-- thread in order to exit the process. When called from another thread,
-- exitWith will throw an ExitException as normal, but
-- the exception will not cause the process itself to exit.
exitWith :: ExitCode -> IO a
-- | The computation exitFailure is equivalent to exitWith
-- (ExitFailure exitfail), where
-- exitfail is implementation-dependent.
exitFailure :: IO a
-- | The computation exitSuccess is equivalent to exitWith
-- ExitSuccess, It terminates the program successfully.
exitSuccess :: IO a
-- | Write given error message to stderr and terminate with
-- exitFailure.
--
-- Since: 4.7.1.0
die :: String -> IO a
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:
--
--
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 ()
-- | unsetEnv 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 Data.Monoid.Compat
-- | The class of monoids (types with an associative binary operation that
-- has an identity). Instances should satisfy the following laws:
--
--
--
-- The method names refer to the monoid of lists under concatenation, but
-- there are many other instances.
--
-- Minimal complete definition: mempty and mappend.
--
-- Some types can be viewed as a monoid in more than one way, e.g. both
-- addition and multiplication on numbers. In such cases we often define
-- newtypes and make those instances of Monoid, e.g.
-- Sum and Product.
class Monoid a
mempty :: Monoid a => a
mappend :: Monoid a => a -> a -> a
mconcat :: Monoid a => [a] -> a
-- | An infix synonym for mappend.
(<>) :: Monoid m => m -> m -> m
-- | The dual of a monoid, obtained by swapping the arguments of
-- mappend.
newtype Dual a :: * -> *
Dual :: a -> Dual a
getDual :: Dual a -> a
-- | The monoid of endomorphisms under composition.
newtype Endo a :: * -> *
Endo :: (a -> a) -> Endo a
appEndo :: Endo a -> a -> a
-- | Boolean monoid under conjunction.
newtype All :: *
All :: Bool -> All
getAll :: All -> Bool
-- | Boolean monoid under disjunction.
newtype Any :: *
Any :: Bool -> Any
getAny :: Any -> Bool
-- | Monoid under addition.
newtype Sum a :: * -> *
Sum :: a -> Sum a
getSum :: Sum a -> a
-- | Monoid under multiplication.
newtype Product a :: * -> *
Product :: a -> Product a
getProduct :: Product a -> a
-- | Maybe monoid returning the leftmost non-Nothing value.
newtype First a :: * -> *
First :: Maybe a -> First a
getFirst :: First a -> Maybe a
-- | Maybe monoid returning the rightmost non-Nothing value.
newtype Last a :: * -> *
Last :: Maybe a -> Last a
getLast :: Last a -> Maybe a
module Data.Foldable.Compat
-- | Data structures that can be folded.
--
-- Minimal complete definition: foldMap or foldr.
--
-- For example, given a data type
--
--
-- data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--
--
-- a suitable instance would be
--
--
-- instance Foldable Tree where
-- foldMap f Empty = mempty
-- foldMap f (Leaf x) = f x
-- foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
--
--
-- This is suitable even for abstract types, as the monoid is assumed to
-- satisfy the monoid laws. Alternatively, one could define
-- foldr:
--
--
-- instance Foldable Tree where
-- foldr f z Empty = z
-- foldr f z (Leaf x) = f x z
-- foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
--
class Foldable (t :: * -> *)
fold :: (Foldable t, Monoid m) => t m -> m
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
foldr' :: Foldable t => (a -> b -> b) -> b -> t a -> b
foldl :: Foldable t => (a -> b -> a) -> a -> t b -> a
foldl' :: Foldable t => (a -> b -> a) -> a -> t b -> a
foldr1 :: Foldable t => (a -> a -> a) -> t a -> a
foldl1 :: Foldable t => (a -> a -> a) -> t a -> a
instance Foldable (Const m)
instance Foldable ((,) a)
instance Foldable (Either a)
module Data.Traversable.Compat
-- | Functors representing data structures that can be traversed from left
-- to right.
--
-- Minimal complete definition: traverse or sequenceA.
--
-- Instances are similar to Functor, e.g. given a data type
--
--
-- data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--
--
-- a suitable instance would be
--
--
-- instance Traversable Tree where
-- traverse f Empty = pure Empty
-- traverse f (Leaf x) = Leaf <$> f x
-- traverse f (Node l k r) = Node <$> traverse f l <*> f k <*> traverse f r
--
--
-- This is suitable even for abstract types, as the laws for
-- <*> imply a form of associativity.
--
-- The superclass instances should satisfy the following:
--
--
-- - In the Functor instance, fmap should be equivalent
-- to traversal with the identity applicative functor
-- (fmapDefault).
-- - In the Foldable instance, foldMap should be
-- equivalent to traversal with a constant applicative functor
-- (foldMapDefault).
--
class (Functor t, Foldable t) => Traversable (t :: * -> *)
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)
instance Traversable (Const m)
instance Traversable ((,) a)
instance Traversable (Either a)
module Data.Either.Compat
-- | Return True if the given value is a Left-value,
-- False otherwise.
--
-- Since: 4.7.0.0
isLeft :: Either a b -> Bool
-- | Return True if the given value is a Right-value,
-- False otherwise.
--
-- Since: 4.7.0.0
isRight :: Either a b -> Bool
module Data.Bool.Compat
data Bool :: *
False :: Bool
True :: Bool
-- | Boolean "and"
(&&) :: Bool -> Bool -> Bool
-- | Boolean "or"
(||) :: Bool -> Bool -> Bool
-- | Boolean "not"
not :: Bool -> Bool
-- | otherwise is defined as the value True. It helps to make
-- guards more readable. eg.
--
--
-- f x | x < 0 = ...
-- | otherwise = ...
--
otherwise :: Bool
-- | Case analysis for the Bool type. bool a b p evaluates
-- to a when p is False, and evaluates to
-- b when p is True.
--
-- Since: 4.7.0.0
bool :: a -> a -> Bool -> a
module Control.Monad.Compat
-- | void value discards or ignores the result of
-- evaluation, such as the return value of an IO action.
void :: Functor f => f a -> f ()
module Data.Functor.Compat
-- | Flipped version of $>.
--
-- Since: 4.7.0.0
($>) :: 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.
void :: Functor f => f a -> f ()
module Control.Exception.Compat
instance Ord ErrorCall
module Control.Applicative.Compat
newtype Const a b :: * -> * -> *
Const :: a -> Const a b
getConst :: Const a b -> a
newtype WrappedMonad (m :: * -> *) a :: (* -> *) -> * -> *
WrapMonad :: m a -> WrappedMonad a
unwrapMonad :: WrappedMonad a -> m a
instance Monad m => Monad (WrappedMonad m)
instance Monoid a => Monoid (Const a b)
module Prelude.Compat