base-3.0.2.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
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 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
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 CUIntMax
Eq CIntMax
Eq CUIntPtr
Eq CIntPtr
Eq CTime
Eq CClock
Eq CSigAtomic
Eq CWchar
Eq CSize
Eq CPtrdiff
Eq CLDouble
Eq CDouble
Eq CFloat
Eq CULLong
Eq CLLong
Eq CULong
Eq CLong
Eq CUInt
Eq CInt
Eq CUShort
Eq CShort
Eq CUChar
Eq CSChar
Eq CChar
Eq IOMode
Eq IOErrorType
Eq IOException
Eq ExitCode
Eq ArrayException
Eq AsyncException
Eq ArithException
Eq Exception
Eq BufferMode
Eq BufferState
Eq Handle
Eq GeneralCategory
Eq Inserts
Eq HashData
Eq KeyPr
Eq Key
Eq IntPtr
Eq WordPtr
Eq Errno
Eq Fd
Eq CRLim
Eq CTcflag
Eq CSpeed
Eq CCc
Eq CUid
Eq CNlink
Eq CGid
Eq CSsize
Eq CPid
Eq COff
Eq CMode
Eq CIno
Eq CDev
Eq FDType
Eq ThreadId
Eq SeekMode
Eq HandlePosn
Eq Any
Eq All
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 (IORef a)
Eq (MVar a)
Eq (ForeignPtr a)
Eq (TVar a)
Eq a => Eq (Last a)
Eq a => Eq (First a)
Eq a => Eq (Product a)
Eq a => Eq (Sum a)
Eq a => Eq (Dual 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 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
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 CUIntMax
Ord CIntMax
Ord CUIntPtr
Ord CIntPtr
Ord CTime
Ord CClock
Ord CSigAtomic
Ord CWchar
Ord CSize
Ord CPtrdiff
Ord CLDouble
Ord CDouble
Ord CFloat
Ord CULLong
Ord CLLong
Ord CULong
Ord CLong
Ord CUInt
Ord CInt
Ord CUShort
Ord CShort
Ord CUChar
Ord CSChar
Ord CChar
Ord IOMode
Ord ExitCode
Ord ArrayException
Ord AsyncException
Ord ArithException
Ord BufferMode
Ord GeneralCategory
Ord IntPtr
Ord WordPtr
Ord Fd
Ord CRLim
Ord CTcflag
Ord CSpeed
Ord CCc
Ord CUid
Ord CNlink
Ord CGid
Ord CSsize
Ord CPid
Ord COff
Ord CMode
Ord CIno
Ord CDev
Ord ThreadId
Ord SeekMode
Ord Any
Ord All
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 (Last a)
Ord a => Ord (First a)
Ord a => Ord (Product a)
Ord a => Ord (Sum a)
Ord a => Ord (Dual 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 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
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] -> 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
Bounded ()
Enum ()
Eq ()
Data ()
Ord ()
Read ()
Show ()
Ix ()
Typeable ()
Monoid ()
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
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
flip :: (a -> b -> c) -> b -> a -> cSource
flip f takes its (first) two arguments in the reverse order of f.
($) :: (a -> b) -> a -> bSource
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
negateInt :: Int -> IntSource
geInt :: 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.3.0