base-3.0.2.0: Basic librariesContentsIndex
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
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
negateInt :: Int -> Int
geInt :: 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 where

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 -> Bool
(/=) :: a -> a -> Bool
show/hide Instances
Eq Bool
Eq Char
Eq Double
Eq Float
Eq Int
Eq Int8
Eq Int16
Eq Int32
Eq Int64
Eq Integer
Eq Ordering
Eq Word
Eq Word8
Eq Word16
Eq Word32
Eq Word64
Eq ()
Eq TyCon
Eq TypeRep
Eq Lexeme
Eq CChar
Eq CSChar
Eq CUChar
Eq CShort
Eq CUShort
Eq CInt
Eq CUInt
Eq CLong
Eq CULong
Eq CLLong
Eq CULLong
Eq CFloat
Eq CDouble
Eq CLDouble
Eq CPtrdiff
Eq CSize
Eq CWchar
Eq CSigAtomic
Eq CClock
Eq CTime
Eq CIntPtr
Eq CUIntPtr
Eq CIntMax
Eq CUIntMax
Eq IOMode
Eq BufferMode
Eq BufferState
Eq ExitCode
Eq AsyncException
Eq ArrayException
Eq ArithException
Eq IOErrorType
Eq Handle
Eq IOException
Eq Exception
Eq GeneralCategory
Eq HashData
Eq Inserts
Eq KeyPr
Eq Key
Eq IntPtr
Eq WordPtr
Eq Errno
Eq CSsize
Eq CCc
Eq CSpeed
Eq CTcflag
Eq CRLim
Eq Fd
Eq CNlink
Eq CUid
Eq CGid
Eq CDev
Eq CIno
Eq CMode
Eq COff
Eq CPid
Eq FDType
Eq ThreadId
Eq SeekMode
Eq HandlePosn
Eq All
Eq Any
Eq Unique
Eq Timeout
Eq Version
Eq Fixity
Eq ConstrRep
Eq DataRep
Eq Constr
Eq a => Eq ([] a)
Integral a => Eq (Ratio a)
Eq (StablePtr a)
Eq (Ptr a)
Eq (FunPtr a)
Eq a => Eq ([::] a)
Eq a => Eq (Maybe a)
Eq (MVar a)
Eq (IORef a)
Eq (ForeignPtr a)
Eq (TVar a)
Eq a => Eq (Dual a)
Eq a => Eq (Sum a)
Eq a => Eq (Product a)
Eq a => Eq (First a)
Eq a => Eq (Last a)
Eq (Fixed a)
Eq (StableName a)
RealFloat a => Eq (Complex a)
(Eq a, Eq b) => Eq (Either a b)
(Eq a, Eq b) => Eq ((,) a b)
Eq (STRef s a)
(Ix i, Eq e) => Eq (Array i e)
Eq (IOArray i e)
(Eq a, Eq b, Eq c) => Eq ((,,) a b c)
Eq (STArray s i e)
(Eq a, Eq b, Eq c, Eq d) => Eq ((,,,) a b c d)
(Eq a, Eq b, Eq c, Eq d, Eq e) => Eq ((,,,,) a b c d e)
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => Eq ((,,,,,) a b c d e f)
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => Eq ((,,,,,,) a b c d e f g)
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => Eq ((,,,,,,,) a b c d e f g h)
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i) => Eq ((,,,,,,,,) a b c d e f g h i)
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j) => Eq ((,,,,,,,,,) a b c d e f g h i j)
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => Eq ((,,,,,,,,,,) a b c d e f g h i j k)
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => Eq ((,,,,,,,,,,,) a b c d e f g h i j k l)
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m) => Eq ((,,,,,,,,,,,,) a b c d e f g h i j k l m)
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n) => Eq ((,,,,,,,,,,,,,) a b c d e f g h i j k l m n)
(Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o) => Eq ((,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o)
class Eq a => Ord a where

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 -> Ordering
(<) :: a -> a -> Bool
(>=) :: a -> a -> Bool
(>) :: a -> a -> Bool
(<=) :: a -> a -> Bool
max :: a -> a -> a
min :: a -> a -> a
show/hide Instances
Ord Bool
Ord Char
Ord Double
Ord Float
Ord Int
Ord Int8
Ord Int16
Ord Int32
Ord Int64
Ord Integer
Ord Ordering
Ord Word
Ord Word8
Ord Word16
Ord Word32
Ord Word64
Ord ()
Ord CChar
Ord CSChar
Ord CUChar
Ord CShort
Ord CUShort
Ord CInt
Ord CUInt
Ord CLong
Ord CULong
Ord CLLong
Ord CULLong
Ord CFloat
Ord CDouble
Ord CLDouble
Ord CPtrdiff
Ord CSize
Ord CWchar
Ord CSigAtomic
Ord CClock
Ord CTime
Ord CIntPtr
Ord CUIntPtr
Ord CIntMax
Ord CUIntMax
Ord IOMode
Ord BufferMode
Ord ExitCode
Ord AsyncException
Ord ArrayException
Ord ArithException
Ord GeneralCategory
Ord IntPtr
Ord WordPtr
Ord CSsize
Ord CCc
Ord CSpeed
Ord CTcflag
Ord CRLim
Ord Fd
Ord CNlink
Ord CUid
Ord CGid
Ord CDev
Ord CIno
Ord CMode
Ord COff
Ord CPid
Ord ThreadId
Ord SeekMode
Ord All
Ord Any
Ord Unique
Ord Version
Ord a => Ord ([] a)
Integral a => Ord (Ratio a)
Ord (Ptr a)
Ord (FunPtr a)
Ord a => Ord ([::] a)
Ord a => Ord (Maybe a)
Ord (ForeignPtr a)
Ord a => Ord (Dual a)
Ord a => Ord (Sum a)
Ord a => Ord (Product a)
Ord a => Ord (First a)
Ord a => Ord (Last a)
Ord (Fixed a)
(Ord a, Ord b) => Ord (Either a b)
(Ord a, Ord b) => Ord ((,) a b)
(Ix i, Ord e) => Ord (Array i e)
(Ord a, Ord b, Ord c) => Ord ((,,) a b c)
(Ord a, Ord b, Ord c, Ord d) => Ord ((,,,) a b c d)
(Ord a, Ord b, Ord c, Ord d, Ord e) => Ord ((,,,,) a b c d e)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f) => Ord ((,,,,,) a b c d e f)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g) => Ord ((,,,,,,) a b c d e f g)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h) => Ord ((,,,,,,,) a b c d e f g h)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i) => Ord ((,,,,,,,,) a b c d e f g h i)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j) => Ord ((,,,,,,,,,) a b c d e f g h i j)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k) => Ord ((,,,,,,,,,,) a b c d e f g h i j k)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l) => Ord ((,,,,,,,,,,,) a b c d e f g h i j k l)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m) => Ord ((,,,,,,,,,,,,) a b c d e f g h i j k l m)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n) => Ord ((,,,,,,,,,,,,,) a b c d e f g h i j k l m n)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o) => Ord ((,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o)
class Functor f where

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 b
show/hide Instances
class Monad m where

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 b
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 b
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
return :: a -> m a
Inject a value into the monadic type.
fail :: String -> 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.
show/hide Instances
data [] a
Constructors
[]
a : [a]
show/hide Instances
Monad []
Functor []
Typeable1 []
MonadFix []
MonadPlus []
Alternative []
Applicative []
Foldable []
Traversable []
Eq a => Eq ([] a)
Data a => Data ([] a)
Ord a => Ord ([] a)
Read a => Read ([] a)
Show a => Show ([] a)
IsString ([] Char)
Monoid ([] a)
IsChar c => PrintfArg ([] c)
IsChar c => PrintfType ([] c)
foldr :: (a -> b -> b) -> b -> [a] -> b

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]

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]

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]

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 -> lst
(++) :: [a] -> [a] -> [a]

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
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 -> Bool
Boolean "and"
(||) :: Bool -> Bool -> Bool
Boolean "or"
not :: Bool -> Bool
Boolean "not"
otherwise :: Bool

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

  f x | x < 0     = ...
      | otherwise = ...
data ()
The unit datatype () has one non-undefined member, the nullary constructor ().
Constructors
()
show/hide Instances
Bounded ()
Enum ()
Eq ()
Data ()
Ord ()
Read ()
Show ()
Ix ()
Typeable ()
Monoid ()
data Ordering
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]
A String is a list of characters. String constants in Haskell are values of type String.
data Char

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 -> Char
The Prelude.toEnum method restricted to the type Data.Char.Char.
unsafeChr :: Int -> Char
ord :: Char -> Int
The Prelude.fromEnum method restricted to the type Data.Char.Char.
eqString :: String -> String -> Bool
data Int
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 :: Int
compareInt :: Int -> Int -> Ordering
compareInt# :: Int# -> Int# -> Ordering
id :: a -> a
Identity function.
lazy :: a -> a
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 -> a
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 -> a

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 -> a
breakpointCond :: Bool -> a -> a
data Opaque
Constructors
forall a . O a
const :: a -> b -> a
Constant function.
(.) :: (b -> c) -> (a -> b) -> a -> c
flip :: (a -> b -> c) -> b -> a -> c
flip f takes its (first) two arguments in the reverse order of f.
($) :: (a -> b) -> a -> b
until :: (a -> Bool) -> (a -> a) -> a -> a
until p f yields the result of applying f until p holds.
asTypeOf :: a -> a -> a
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
Constructors
Unit
data a :+: b
Constructors
Inl a
Inr b
data a :*: b
Constructors
a :*: b
getTag :: a -> Int#
divInt# :: Int# -> Int# -> Int#
modInt# :: Int# -> Int# -> Int#
minusInt :: Int -> Int -> Int
negateInt :: Int -> Int
geInt :: Int -> Int -> Bool
shiftL# :: Word# -> Int# -> Word#
Shift the argument left by the specified number of bits (which must be non-negative).
shiftRL# :: Word# -> Int# -> Word#
Shift the argument right by the specified number of bits (which must be non-negative).
iShiftL# :: Int# -> Int# -> Int#
Shift the argument left by the specified number of bits (which must be non-negative).
iShiftRA# :: Int# -> Int# -> Int#
Shift the argument right (signed) by the specified number of bits (which must be non-negative).
iShiftRL# :: Int# -> Int# -> Int#
Shift the argument right (unsigned) by the specified number of bits (which must be non-negative).
unpackCString# :: Addr# -> [Char]
unpackAppendCString# :: Addr# -> [Char] -> [Char]
unpackFoldrCString# :: Addr# -> (Char -> a -> a) -> a -> a
unpackCStringUtf8# :: Addr# -> [Char]
unpackNBytes# :: Addr# -> Int# -> [Char]
module GHC.Err
Produced by Haddock version 2.2.2