base-3.0.1.0: Basic librariesSource codeContentsIndex
GHC.Base
Portabilitynon-portable (GHC extensions)
Stabilityinternal
Maintainercvs-ghc@haskell.org
Description
Basic data types and classes.
Synopsis
class Eq a where
(==) :: a -> a -> Bool
(/=) :: a -> a -> Bool
class Eq a => Ord a where
compare :: a -> a -> Ordering
(<) :: a -> a -> Bool
(>=) :: a -> a -> Bool
(>) :: a -> a -> Bool
(<=) :: a -> a -> Bool
max :: a -> a -> a
min :: a -> a -> a
class Functor f where
fmap :: (a -> b) -> f a -> f b
class Monad m where
(>>=) :: forall a b. m a -> (a -> m b) -> m b
(>>) :: forall a b. m a -> m b -> m b
return :: a -> m a
fail :: String -> m a
data [] a
= []
| a : [a]
foldr :: (a -> b -> b) -> b -> [a] -> b
build :: forall a. (forall b. (a -> b -> b) -> b -> b) -> [a]
augment :: forall a. (forall b. (a -> b -> b) -> b -> b) -> [a] -> [a]
map :: (a -> b) -> [a] -> [b]
mapFB :: (elt -> lst -> lst) -> (a -> elt) -> a -> lst -> lst
(++) :: [a] -> [a] -> [a]
data Bool
= False
| True
(&&) :: Bool -> Bool -> Bool
(||) :: Bool -> Bool -> Bool
not :: Bool -> Bool
otherwise :: Bool
data () = ()
data Ordering
= LT
| EQ
| GT
type String = [Char]
data Char = C# Char#
chr :: Int -> Char
unsafeChr :: Int -> Char
ord :: Char -> Int
eqString :: String -> String -> Bool
data Int = I# Int#
oneInt :: Int
twoInt :: Int
maxInt :: Int
minInt :: Int
zeroInt :: Int
compareInt :: Int -> Int -> Ordering
compareInt# :: Int# -> Int# -> Ordering
id :: a -> a
lazy :: a -> a
inline :: a -> a
assert :: Bool -> a -> a
breakpoint :: a -> a
breakpointCond :: Bool -> a -> a
data Opaque = forall a . O a
const :: a -> b -> a
(.) :: (b -> c) -> (a -> b) -> a -> c
flip :: (a -> b -> c) -> b -> a -> c
($) :: (a -> b) -> a -> b
until :: (a -> Bool) -> (a -> a) -> a -> a
asTypeOf :: a -> a -> a
data Unit = Unit
data a :+: b
= Inl a
| Inr b
data a :*: b = a :*: b
getTag :: a -> Int#
divInt# :: Int# -> Int# -> Int#
modInt# :: Int# -> Int# -> Int#
minusInt :: Int -> Int -> Int
timesInt :: Int -> Int -> Int
quotInt :: Int -> Int -> Int
remInt :: Int -> Int -> Int
divInt :: Int -> Int -> Int
modInt :: Int -> Int -> Int
gcdInt :: Int -> Int -> Int
plusInt :: Int -> Int -> Int
negateInt :: Int -> Int
geInt :: Int -> Int -> Bool
eqInt :: Int -> Int -> Bool
neInt :: Int -> Int -> Bool
ltInt :: Int -> Int -> Bool
leInt :: Int -> Int -> Bool
gtInt :: Int -> Int -> Bool
shiftL# :: Word# -> Int# -> Word#
shiftRL# :: Word# -> Int# -> Word#
iShiftL# :: Int# -> Int# -> Int#
iShiftRA# :: Int# -> Int# -> Int#
iShiftRL# :: Int# -> Int# -> Int#
unpackCString# :: Addr# -> [Char]
unpackAppendCString# :: Addr# -> [Char] -> [Char]
unpackFoldrCString# :: Addr# -> (Char -> a -> a) -> a -> a
unpackCStringUtf8# :: Addr# -> [Char]
unpackNBytes# :: Addr# -> Int# -> [Char]
module GHC.Err
Documentation
class Eq a whereSource

The Eq class defines equality (==) and inequality (/=). All the basic datatypes exported by the Prelude are instances of Eq, and Eq may be derived for any datatype whose constituents are also instances of Eq.

Minimal complete definition: either == or /=.

Methods
(==) :: a -> a -> BoolSource
(/=) :: a -> a -> BoolSource
show/hide Instances
class Eq a => Ord a whereSource

The Ord class is used for totally ordered datatypes.

Instances of Ord can be derived for any user-defined datatype whose constituent types are in Ord. The declared order of the constructors in the data declaration determines the ordering in derived Ord instances. The Ordering datatype allows a single comparison to determine the precise ordering of two objects.

Minimal complete definition: either compare or <=. Using compare can be more efficient for complex types.

Methods
compare :: a -> a -> OrderingSource
(<) :: a -> a -> BoolSource
(>=) :: a -> a -> BoolSource
(>) :: a -> a -> BoolSource
(<=) :: a -> a -> BoolSource
max :: a -> a -> aSource
min :: a -> a -> aSource
show/hide Instances
class Functor f whereSource

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, Data.Maybe.Maybe and System.IO.IO defined in the Prelude satisfy these laws.

Methods
fmap :: (a -> b) -> f a -> f bSource
show/hide Instances
class Monad m whereSource

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.

Minimal complete definition: >>= and return.

Instances of Monad should satisfy the following laws:

 return a >>= k  ==  k a
 m >>= return  ==  m
 m >>= (\x -> k x >>= h)  ==  (m >>= k) >>= h

Instances of both Monad and Functor should additionally satisfy the law:

 fmap f xs  ==  xs >>= return . f

The instances of Monad for lists, Data.Maybe.Maybe and System.IO.IO defined in the Prelude satisfy these laws.

Methods
(>>=) :: forall a b. m a -> (a -> m b) -> m bSource
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
(>>) :: forall a b. m a -> m b -> m bSource
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
return :: a -> m aSource
Inject a value into the monadic type.
fail :: String -> m aSource
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.
show/hide Instances
data [] a Source
Constructors
[]
a : [a]
show/hide Instances
foldr :: (a -> b -> b) -> b -> [a] -> bSource

foldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left:

 foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
build :: forall a. (forall b. (a -> b -> b) -> b -> b) -> [a]Source

A list producer that can be fused with foldr. This function is merely

	build g = g (:) []

but GHC's simplifier will transform an expression of the form foldr k z (build g), which may arise after inlining, to g k z, which avoids producing an intermediate list.

augment :: forall a. (forall b. (a -> b -> b) -> b -> b) -> [a] -> [a]Source

A list producer that can be fused with foldr. This function is merely

	augment g xs = g (:) xs

but GHC's simplifier will transform an expression of the form foldr k z (augment g xs), which may arise after inlining, to g k (foldr k z xs), which avoids producing an intermediate list.

map :: (a -> b) -> [a] -> [b]Source

map f xs is the list obtained by applying f to each element of xs, i.e.,

 map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
 map f [x1, x2, ...] == [f x1, f x2, ...]
mapFB :: (elt -> lst -> lst) -> (a -> elt) -> a -> lst -> lstSource
(++) :: [a] -> [a] -> [a]Source

Append two lists, i.e.,

 [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
 [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]

If the first list is not finite, the result is the first list.

data Bool Source
The Bool type is an enumeration. It is defined with False first so that the corresponding Prelude.Enum instance will give Prelude.fromEnum False the value zero, and Prelude.fromEnum True the value 1.
Constructors
False
True
show/hide Instances
(&&) :: Bool -> Bool -> BoolSource
Boolean "and"
(||) :: Bool -> Bool -> BoolSource
Boolean "or"
not :: Bool -> BoolSource
Boolean "not"
otherwise :: BoolSource

otherwise is defined as the value True. It helps to make guards more readable. eg.

  f x | x < 0     = ...
      | otherwise = ...
data () Source
The unit datatype () has one non-undefined member, the nullary constructor ().
Constructors
()
show/hide Instances
data Ordering Source
Represents an ordering relationship between two values: less than, equal to, or greater than. An Ordering is returned by compare.
Constructors
LT
EQ
GT
show/hide Instances
type String = [Char]Source
A String is a list of characters. String constants in Haskell are values of type String.
data Char Source

The character type Char is an enumeration whose values represent Unicode (or equivalently ISO/IEC 10646) characters (see http://www.unicode.org/ for details). This set extends the ISO 8859-1 (Latin-1) character set (the first 256 charachers), which is itself an extension of the ASCII character set (the first 128 characters). A character literal in Haskell has type Char.

To convert a Char to or from the corresponding Int value defined by Unicode, use Prelude.toEnum and Prelude.fromEnum from the Prelude.Enum class respectively (or equivalently ord and chr).

Constructors
C# Char#
show/hide Instances
chr :: Int -> CharSource
The Prelude.toEnum method restricted to the type Data.Char.Char.
unsafeChr :: Int -> CharSource
ord :: Char -> IntSource
The Prelude.fromEnum method restricted to the type Data.Char.Char.
eqString :: String -> String -> BoolSource
data Int Source
A fixed-precision integer type with at least the range [-2^29 .. 2^29-1]. The exact range for a given implementation can be determined by using Prelude.minBound and Prelude.maxBound from the Prelude.Bounded class.
Constructors
I# Int#
show/hide Instances
oneInt :: IntSource
twoInt :: IntSource
maxInt :: IntSource
minInt :: IntSource
zeroInt :: IntSource
compareInt :: Int -> Int -> OrderingSource
compareInt# :: Int# -> Int# -> OrderingSource
id :: a -> aSource
Identity function.
lazy :: a -> aSource
The call '(lazy e)' means the same as e, but lazy has a magical strictness property: it is lazy in its first argument, even though its semantics is strict.
inline :: a -> aSource
The call '(inline f)' reduces to f, but inline has a BuiltInRule that tries to inline f (if it has an unfolding) unconditionally The NOINLINE pragma arranges that inline only gets inlined (and hence eliminated) late in compilation, after the rule has had a god chance to fire.
assert :: Bool -> a -> aSource

If the first argument evaluates to True, then the result is the second argument. Otherwise an AssertionFailed exception is raised, containing a String with the source file and line number of the call to assert.

Assertions can normally be turned on or off with a compiler flag (for GHC, assertions are normally on unless optimisation is turned on with -O or the -fignore-asserts option is given). When assertions are turned off, the first argument to assert is ignored, and the second argument is returned as the result.

breakpoint :: a -> aSource
breakpointCond :: Bool -> a -> aSource
data Opaque Source
Constructors
forall a . O a
const :: a -> b -> aSource
Constant function.
(.) :: (b -> c) -> (a -> b) -> a -> cSource
Function composition.
flip :: (a -> b -> c) -> b -> a -> cSource
flip f takes its (first) two arguments in the reverse order of f.
($) :: (a -> b) -> a -> bSource

Application operator. This operator is redundant, since ordinary application (f x) means the same as (f $ x). However, $ has low, right-associative binding precedence, so it sometimes allows parentheses to be omitted; for example:

     f $ g $ h x  =  f (g (h x))

It is also useful in higher-order situations, such as map ($ 0) xs, or Data.List.zipWith ($) fs xs.

until :: (a -> Bool) -> (a -> a) -> a -> aSource
until p f yields the result of applying f until p holds.
asTypeOf :: a -> a -> aSource
asTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the second.
data Unit Source
Constructors
Unit
data a :+: b Source
Constructors
Inl a
Inr b
data a :*: b Source
Constructors
a :*: b
getTag :: a -> Int#Source
divInt# :: Int# -> Int# -> Int#Source
modInt# :: Int# -> Int# -> Int#Source
minusInt :: Int -> Int -> IntSource
timesInt :: Int -> Int -> IntSource
quotInt :: Int -> Int -> IntSource
remInt :: Int -> Int -> IntSource
divInt :: Int -> Int -> IntSource
modInt :: Int -> Int -> IntSource
gcdInt :: Int -> Int -> IntSource
plusInt :: Int -> Int -> IntSource
negateInt :: Int -> IntSource
geInt :: Int -> Int -> BoolSource
eqInt :: Int -> Int -> BoolSource
neInt :: Int -> Int -> BoolSource
ltInt :: Int -> Int -> BoolSource
leInt :: Int -> Int -> BoolSource
gtInt :: Int -> Int -> BoolSource
shiftL# :: Word# -> Int# -> Word#Source
Shift the argument left by the specified number of bits (which must be non-negative).
shiftRL# :: Word# -> Int# -> Word#Source
Shift the argument right by the specified number of bits (which must be non-negative).
iShiftL# :: Int# -> Int# -> Int#Source
Shift the argument left by the specified number of bits (which must be non-negative).
iShiftRA# :: Int# -> Int# -> Int#Source
Shift the argument right (signed) by the specified number of bits (which must be non-negative).
iShiftRL# :: Int# -> Int# -> Int#Source
Shift the argument right (unsigned) by the specified number of bits (which must be non-negative).
unpackCString# :: Addr# -> [Char]Source
unpackAppendCString# :: Addr# -> [Char] -> [Char]Source
unpackFoldrCString# :: Addr# -> (Char -> a -> a) -> a -> aSource
unpackCStringUtf8# :: Addr# -> [Char]Source
unpackNBytes# :: Addr# -> Int# -> [Char]Source
module GHC.Err
Produced by Haddock version 2.0.0.0