ghc-prim-0.11.0: GHC primitives
Copyright(c) The University of Glasgow 2009
Licensesee libraries/ghc-prim/LICENSE
Maintainercvs-ghc@haskell.org
Stabilityinternal
Portabilitynon-portable (GHC Extensions)
Safe HaskellNone
LanguageHaskell2010

GHC.Types

Description

GHC type definitions. Use GHC.Exts from the base package instead of importing this module directly.

Synopsis

Documentation

data List a Source #

The builtin list type, usually written in its non-prefix form [a].

Examples

Expand

Unless the OverloadedLists extension is enabled, list literals are syntactic sugar for repeated applications of : and [].

>>> 1:2:3:4:[] == [1,2,3,4]
True

Similarly, unless the OverloadedStrings extension is enabled, string literals are syntactic sugar for a lists of characters.

>>> ['h','e','l','l','o'] == "hello"
True

Since: ghc-prim-0.10.0

Constructors

[] 
a : [a] infixr 5 

Instances

Instances details
Eq a => Eq [a] Source # 
Instance details

Defined in GHC.Classes

Methods

(==) :: [a] -> [a] -> Bool Source #

(/=) :: [a] -> [a] -> Bool Source #

Ord a => Ord [a] Source # 
Instance details

Defined in GHC.Classes

Methods

compare :: [a] -> [a] -> Ordering Source #

(<) :: [a] -> [a] -> Bool Source #

(<=) :: [a] -> [a] -> Bool Source #

(>) :: [a] -> [a] -> Bool Source #

(>=) :: [a] -> [a] -> Bool Source #

max :: [a] -> [a] -> [a] Source #

min :: [a] -> [a] -> [a] Source #

class a ~# b => (a :: k) ~ (b :: k) infix 4 Source #

Lifted, homogeneous equality. By lifted, we mean that it can be bogus (deferred type error). By homogeneous, the two types a and b must have the same kinds.

Built-in types

data Bool Source #

Constructors

False 
True 

Instances

Instances details
Eq Bool Source # 
Instance details

Defined in GHC.Classes

Methods

(==) :: Bool -> Bool -> Bool Source #

(/=) :: Bool -> Bool -> Bool Source #

Ord Bool Source # 
Instance details

Defined in GHC.Classes

data Char Source #

The character type Char represents Unicode codespace and its elements are code points as in definitions D9 and D10 of the Unicode Standard.

Character literals in Haskell are single-quoted: 'Q', 'Я' or 'Ω'. To represent a single quote itself use '\'', and to represent a backslash use '\\'. The full grammar can be found in the section 2.6 of the Haskell 2010 Language Report.

To specify a character by its code point one can use decimal, hexadecimal or octal notation: '\65', '\x41' and '\o101' are all alternative forms of 'A'. The largest code point is '\x10ffff'.

There is a special escape syntax for ASCII control characters:

EscapeAlternativesMeaning
'\NUL''\0'null character
'\SOH''\1'start of heading
'\STX''\2'start of text
'\ETX''\3'end of text
'\EOT''\4'end of transmission
'\ENQ''\5'enquiry
'\ACK''\6'acknowledge
'\BEL''\7', '\a'bell (alert)
'\BS''\8', '\b'backspace
'\HT''\9', '\t'horizontal tab
'\LF''\10', '\n'line feed (new line)
'\VT''\11', '\v'vertical tab
'\FF''\12', '\f'form feed
'\CR''\13', '\r'carriage return
'\SO''\14'shift out
'\SI''\15'shift in
'\DLE''\16'data link escape
'\DC1''\17'device control 1
'\DC2''\18'device control 2
'\DC3''\19'device control 3
'\DC4''\20'device control 4
'\NAK''\21'negative acknowledge
'\SYN''\22'synchronous idle
'\ETB''\23'end of transmission block
'\CAN''\24'cancel
'\EM''\25'end of medium
'\SUB''\26'substitute
'\ESC''\27'escape
'\FS''\28'file separator
'\GS''\29'group separator
'\RS''\30'record separator
'\US''\31'unit separator
'\SP''\32', ' 'space
'\DEL''\127'delete

Data.Char provides utilities to work with Char.

Constructors

C# Char# 

Instances

Instances details
Eq Char Source # 
Instance details

Defined in GHC.Classes

Methods

(==) :: Char -> Char -> Bool Source #

(/=) :: Char -> Char -> Bool Source #

Ord Char Source # 
Instance details

Defined in GHC.Classes

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 minBound and maxBound from the Bounded class.

Constructors

I# Int# 

Instances

Instances details
Eq Int Source # 
Instance details

Defined in GHC.Classes

Methods

(==) :: Int -> Int -> Bool Source #

(/=) :: Int -> Int -> Bool Source #

Ord Int Source # 
Instance details

Defined in GHC.Classes

Methods

compare :: Int -> Int -> Ordering Source #

(<) :: Int -> Int -> Bool Source #

(<=) :: Int -> Int -> Bool Source #

(>) :: Int -> Int -> Bool Source #

(>=) :: Int -> Int -> Bool Source #

max :: Int -> Int -> Int Source #

min :: Int -> Int -> Int Source #

data Word Source #

A Word is an unsigned integral type, with the same size as Int.

Constructors

W# Word# 

Instances

Instances details
Eq Word Source # 
Instance details

Defined in GHC.Classes

Methods

(==) :: Word -> Word -> Bool Source #

(/=) :: Word -> Word -> Bool Source #

Ord Word Source # 
Instance details

Defined in GHC.Classes

data Float Source #

Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.

Constructors

F# Float# 

Instances

Instances details
Eq Float Source #

Note that due to the presence of NaN, Float's Eq instance does not satisfy reflexivity.

>>> 0/0 == (0/0 :: Float)
False

Also note that Float's Eq instance does not satisfy extensionality:

>>> 0 == (-0 :: Float)
True
>>> recip 0 == recip (-0 :: Float)
False
Instance details

Defined in GHC.Classes

Methods

(==) :: Float -> Float -> Bool Source #

(/=) :: Float -> Float -> Bool Source #

Ord Float Source #

See instance Ord Double for discussion of deviations from IEEE 754 standard.

Instance details

Defined in GHC.Classes

data Double Source #

Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.

Constructors

D# Double# 

Instances

Instances details
Eq Double Source #

Note that due to the presence of NaN, Double's Eq instance does not satisfy reflexivity.

>>> 0/0 == (0/0 :: Double)
False

Also note that Double's Eq instance does not satisfy substitutivity:

>>> 0 == (-0 :: Double)
True
>>> recip 0 == recip (-0 :: Double)
False
Instance details

Defined in GHC.Classes

Ord Double Source #

IEEE 754 Double-precision type includes not only numbers, but also positive and negative infinities and a special element called NaN (which can be quiet or signal).

IEEE 754-2008, section 5.11 requires that if at least one of arguments of <=, <, >, >= is NaN then the result of the comparison is False, and instance Ord Double complies with this requirement. This violates the reflexivity: both NaN <= NaN and NaN >= NaN are False.

IEEE 754-2008, section 5.10 defines totalOrder predicate. Unfortunately, compare on Doubles violates the IEEE standard and does not define a total order. More specifically, both compare NaN x and compare x NaN always return GT.

Thus, users must be extremely cautious when using instance Ord Double. For instance, one should avoid ordered containers with keys represented by Double, because data loss and corruption may happen. An IEEE-compliant compare is available in fp-ieee package as TotallyOrdered newtype.

Moving further, the behaviour of min and max with regards to NaN is also non-compliant. IEEE 754-2008, section 5.3.1 defines that quiet NaN should be treated as a missing data by minNum and maxNum functions, for example, minNum(NaN, 1) = minNum(1, NaN) = 1. Some languages such as Java deviate from the standard implementing minNum(NaN, 1) = minNum(1, NaN) = NaN. However, min / max in base are even worse: min NaN 1 is 1, but min 1 NaN is NaN.

IEEE 754-2008 compliant min / max can be found in ieee754 package under minNum / maxNum names. Implementations compliant with minimumNumber / maximumNumber from a newer IEEE 754-2019, section 9.6 are available from fp-ieee package.

Instance details

Defined in GHC.Classes

data Ordering Source #

Constructors

LT 
EQ 
GT 

Instances

Instances details
Eq Ordering Source # 
Instance details

Defined in GHC.Classes

Ord Ordering Source # 
Instance details

Defined in GHC.Classes

newtype IO a Source #

A value of type IO a is a computation which, when performed, does some I/O before returning a value of type a.

There is really only one way to "perform" an I/O action: bind it to Main.main in your program. When your program is run, the I/O will be performed. It isn't possible to perform I/O from an arbitrary function, unless that function is itself in the IO monad and called at some point, directly or indirectly, from Main.main.

IO is a monad, so IO actions can be combined using either the do-notation or the >> and >>= operations from the Monad class.

Constructors

IO (State# RealWorld -> (# State# RealWorld, a #)) 

data List a Source #

The builtin list type, usually written in its non-prefix form [a].

Examples

Expand

Unless the OverloadedLists extension is enabled, list literals are syntactic sugar for repeated applications of : and [].

>>> 1:2:3:4:[] == [1,2,3,4]
True

Similarly, unless the OverloadedStrings extension is enabled, string literals are syntactic sugar for a lists of characters.

>>> ['h','e','l','l','o'] == "hello"
True

Since: ghc-prim-0.10.0

Instances

Instances details
Eq a => Eq [a] Source # 
Instance details

Defined in GHC.Classes

Methods

(==) :: [a] -> [a] -> Bool Source #

(/=) :: [a] -> [a] -> Bool Source #

Ord a => Ord [a] Source # 
Instance details

Defined in GHC.Classes

Methods

compare :: [a] -> [a] -> Ordering Source #

(<) :: [a] -> [a] -> Bool Source #

(<=) :: [a] -> [a] -> Bool Source #

(>) :: [a] -> [a] -> Bool Source #

(>=) :: [a] -> [a] -> Bool Source #

max :: [a] -> [a] -> [a] Source #

min :: [a] -> [a] -> [a] Source #

isTrue# :: Int# -> Bool Source #

Alias for tagToEnum#. Returns True if its parameter is 1# and False if it is 0#.

data SPEC Source #

SPEC is used by GHC in the SpecConstr pass in order to inform the compiler when to be particularly aggressive. In particular, it tells GHC to specialize regardless of size or the number of specializations. However, not all loops fall into this category.

Libraries can specify this by using SPEC data type to inform which loops should be aggressively specialized. For example, instead of

loop x where loop arg = ...

write

loop SPEC x where loop !_ arg = ...

There is no semantic difference between SPEC and SPEC2, we just need a type with two contructors lest it is optimised away before SpecConstr.

This type is reexported from GHC.Exts since GHC 9.0 and base-4.15. For compatibility with earlier releases import it from GHC.Types in ghc-prim package.

Since: ghc-prim-0.3.1.0

Constructors

SPEC 
SPEC2 

data Symbol Source #

(Kind) This is the kind of type-level symbols.

type family Any :: k where ... Source #

The type constructor Any is type to which you can unsafely coerce any lifted type, and back. More concretely, for a lifted type t and value x :: t, unsafeCoerce (unsafeCoerce x :: Any) :: t is equivalent to x.

Type equality

class a ~# b => (a :: k) ~ (b :: k) infix 4 Source #

Lifted, homogeneous equality. By lifted, we mean that it can be bogus (deferred type error). By homogeneous, the two types a and b must have the same kinds.

class a ~# b => (a :: k0) ~~ (b :: k1) infix 4 Source #

Lifted, heterogeneous equality. By lifted, we mean that it can be bogus (deferred type error). By heterogeneous, the two types a and b might have different kinds. Because ~~ can appear unexpectedly in error messages to users who do not care about the difference between heterogeneous equality ~~ and homogeneous equality ~, this is printed as ~ unless -fprint-equality-relations is set.

In 0.7.0, the fixity was set to infix 4 to match the fixity of :~~:.

class a ~R# b => Coercible (a :: k) (b :: k) Source #

Coercible is a two-parameter class that has instances for types a and b if the compiler can infer that they have the same representation. This class does not have regular instances; instead they are created on-the-fly during type-checking. Trying to manually declare an instance of Coercible is an error.

Nevertheless one can pretend that the following three kinds of instances exist. First, as a trivial base-case:

instance Coercible a a

Furthermore, for every type constructor there is an instance that allows to coerce under the type constructor. For example, let D be a prototypical type constructor (data or newtype) with three type arguments, which have roles nominal, representational resp. phantom. Then there is an instance of the form

instance Coercible b b' => Coercible (D a b c) (D a b' c')

Note that the nominal type arguments are equal, the representational type arguments can differ, but need to have a Coercible instance themself, and the phantom type arguments can be changed arbitrarily.

The third kind of instance exists for every newtype NT = MkNT T and comes in two variants, namely

instance Coercible a T => Coercible a NT
instance Coercible T b => Coercible NT b

This instance is only usable if the constructor MkNT is in scope.

If, as a library author of a type constructor like Set a, you want to prevent a user of your module to write coerce :: Set T -> Set NT, you need to set the role of Set's type parameter to nominal, by writing

type role Set nominal

For more details about this feature, please refer to Safe Coercions by Joachim Breitner, Richard A. Eisenberg, Simon Peyton Jones and Stephanie Weirich.

Since: ghc-prim-0.4.0

Representation polymorphism

data TYPE (a :: RuntimeRep) Source #

data Levity Source #

Whether a boxed type is lifted or unlifted.

Constructors

Lifted 
Unlifted 

data RuntimeRep Source #

GHC maintains a property that the kind of all inhabited types (as distinct from type constructors or type-level data) tells us the runtime representation of values of that type. This datatype encodes the choice of runtime value. Note that TYPE is parameterised by RuntimeRep; this is precisely what we mean by the fact that a type's kind encodes the runtime representation.

For boxed values (that is, values that are represented by a pointer), a further distinction is made, between lifted types (that contain ⊥), and unlifted ones (that don't).

Constructors

VecRep VecCount VecElem

a SIMD vector type

TupleRep [RuntimeRep]

An unboxed tuple of the given reps

SumRep [RuntimeRep]

An unboxed sum of the given reps

BoxedRep Levity

boxed; represented by a pointer

IntRep

signed, word-sized value

Int8Rep

signed, 8-bit value

Int16Rep

signed, 16-bit value

Int32Rep

signed, 32-bit value

Int64Rep

signed, 64-bit value

WordRep

unsigned, word-sized value

Word8Rep

unsigned, 8-bit value

Word16Rep

unsigned, 16-bit value

Word32Rep

unsigned, 32-bit value

Word64Rep

unsigned, 64-bit value

AddrRep

A pointer, but not to a Haskell value

FloatRep

a 32-bit floating point number

DoubleRep

a 64-bit floating point number

type LiftedRep = 'BoxedRep 'Lifted Source #

The runtime representation of lifted types.

type UnliftedRep = 'BoxedRep 'Unlifted Source #

The runtime representation of unlifted types.

type Type = TYPE LiftedRep Source #

The kind of types with lifted values. For example Int :: Type.

type UnliftedType = TYPE UnliftedRep Source #

The kind of boxed, unlifted values, for example Array# or a user-defined unlifted data type, using -XUnliftedDataTypes.

type Constraint = CONSTRAINT LiftedRep Source #

The kind of lifted constraints

type ZeroBitRep = 'TupleRep ('[] :: [RuntimeRep]) Source #

The runtime representation of a zero-width tuple, represented by no bits at all

type ZeroBitType = TYPE ZeroBitRep Source #

The kind of the empty unboxed tuple type (# #)

data VecCount Source #

Length of a SIMD vector type

Constructors

Vec2 
Vec4 
Vec8 
Vec16 
Vec32 
Vec64 

type Void# = (# #) Source #

Deprecated: Void# is now an alias for the unboxed tuple (# #).

Boxing constructors

data DictBox a Source #

Data type Dict provides a simple way to wrap up a (lifted) constraint as a type

Constructors

a => MkDictBox 

data WordBox (a :: TYPE 'WordRep) Source #

Constructors

MkWordBox a 

data IntBox (a :: TYPE 'IntRep) Source #

Constructors

MkIntBox a 

data FloatBox (a :: TYPE 'FloatRep) Source #

Constructors

MkFloatBox a 

data DoubleBox (a :: TYPE 'DoubleRep) Source #

Constructors

MkDoubleBox a 

Multiplicity types

data Multiplicity Source #

Constructors

One 
Many 

type family MultMul (a :: Multiplicity) (b :: Multiplicity) :: Multiplicity where ... Source #

Equations

MultMul 'One x = x 
MultMul x 'One = x 
MultMul 'Many x = 'Many 
MultMul x 'Many = 'Many 

Runtime type representation

data Module Source #

Constructors

Module 

Fields

Instances

Instances details
Eq Module Source # 
Instance details

Defined in GHC.Classes

data TrName Source #

Constructors

TrNameS Addr#

Static

TrNameD [Char]

Dynamic

Instances

Instances details
Eq TrName Source # 
Instance details

Defined in GHC.Classes

data TyCon Source #

Constructors

TyCon 

Fields

  • Word64#

    Fingerprint (high)

  • Word64#

    Fingerprint (low)

  • Module

    Module in which this is defined

  • TrName

    Type constructor name

  • Int#

    How many kind variables do we accept?

  • KindRep

    A representation of the type's kind

Instances

Instances details
Eq TyCon Source # 
Instance details

Defined in GHC.Classes

Methods

(==) :: TyCon -> TyCon -> Bool Source #

(/=) :: TyCon -> TyCon -> Bool Source #

Ord TyCon Source # 
Instance details

Defined in GHC.Classes

type KindBndr = Int Source #

A de Bruijn index for a binder within a KindRep.