Add Int8# and Word8#
[ghc.git] / compiler / prelude / TysPrim.hs
1 {-
2 (c) The AQUA Project, Glasgow University, 1994-1998
3
4
5 \section[TysPrim]{Wired-in knowledge about primitive types}
6 -}
7
8 {-# LANGUAGE CPP #-}
9
10 -- | This module defines TyCons that can't be expressed in Haskell.
11 -- They are all, therefore, wired-in TyCons. C.f module TysWiredIn
12 module TysPrim(
13 mkPrimTyConName, -- For implicit parameters in TysWiredIn only
14
15 mkTemplateKindVars, mkTemplateTyVars, mkTemplateTyVarsFrom,
16 mkTemplateKiTyVars,
17
18 mkTemplateTyConBinders, mkTemplateKindTyConBinders,
19 mkTemplateAnonTyConBinders,
20
21 alphaTyVars, alphaTyVar, betaTyVar, gammaTyVar, deltaTyVar,
22 alphaTys, alphaTy, betaTy, gammaTy, deltaTy,
23 alphaTyVarsUnliftedRep, alphaTyVarUnliftedRep,
24 alphaTysUnliftedRep, alphaTyUnliftedRep,
25 runtimeRep1TyVar, runtimeRep2TyVar, runtimeRep1Ty, runtimeRep2Ty,
26 openAlphaTy, openBetaTy, openAlphaTyVar, openBetaTyVar,
27
28 -- Kind constructors...
29 tYPETyCon, tYPETyConName,
30
31 -- Kinds
32 tYPE, primRepToRuntimeRep,
33
34 funTyCon, funTyConName,
35 unexposedPrimTyCons, exposedPrimTyCons, primTyCons,
36
37 charPrimTyCon, charPrimTy, charPrimTyConName,
38 intPrimTyCon, intPrimTy, intPrimTyConName,
39 wordPrimTyCon, wordPrimTy, wordPrimTyConName,
40 addrPrimTyCon, addrPrimTy, addrPrimTyConName,
41 floatPrimTyCon, floatPrimTy, floatPrimTyConName,
42 doublePrimTyCon, doublePrimTy, doublePrimTyConName,
43
44 voidPrimTyCon, voidPrimTy,
45 statePrimTyCon, mkStatePrimTy,
46 realWorldTyCon, realWorldTy, realWorldStatePrimTy,
47
48 proxyPrimTyCon, mkProxyPrimTy,
49
50 arrayPrimTyCon, mkArrayPrimTy,
51 byteArrayPrimTyCon, byteArrayPrimTy,
52 arrayArrayPrimTyCon, mkArrayArrayPrimTy,
53 smallArrayPrimTyCon, mkSmallArrayPrimTy,
54 mutableArrayPrimTyCon, mkMutableArrayPrimTy,
55 mutableByteArrayPrimTyCon, mkMutableByteArrayPrimTy,
56 mutableArrayArrayPrimTyCon, mkMutableArrayArrayPrimTy,
57 smallMutableArrayPrimTyCon, mkSmallMutableArrayPrimTy,
58 mutVarPrimTyCon, mkMutVarPrimTy,
59
60 mVarPrimTyCon, mkMVarPrimTy,
61 tVarPrimTyCon, mkTVarPrimTy,
62 stablePtrPrimTyCon, mkStablePtrPrimTy,
63 stableNamePrimTyCon, mkStableNamePrimTy,
64 compactPrimTyCon, compactPrimTy,
65 bcoPrimTyCon, bcoPrimTy,
66 weakPrimTyCon, mkWeakPrimTy,
67 threadIdPrimTyCon, threadIdPrimTy,
68
69 int8PrimTyCon, int8PrimTy,
70 word8PrimTyCon, word8PrimTy,
71
72 int32PrimTyCon, int32PrimTy,
73 word32PrimTyCon, word32PrimTy,
74
75 int64PrimTyCon, int64PrimTy,
76 word64PrimTyCon, word64PrimTy,
77
78 eqPrimTyCon, -- ty1 ~# ty2
79 eqReprPrimTyCon, -- ty1 ~R# ty2 (at role Representational)
80 eqPhantPrimTyCon, -- ty1 ~P# ty2 (at role Phantom)
81
82 -- * SIMD
83 #include "primop-vector-tys-exports.hs-incl"
84 ) where
85
86 #include "HsVersions.h"
87
88 import GhcPrelude
89
90 import {-# SOURCE #-} TysWiredIn
91 ( runtimeRepTy, unboxedTupleKind, liftedTypeKind
92 , vecRepDataConTyCon, tupleRepDataConTyCon
93 , liftedRepDataConTy, unliftedRepDataConTy, intRepDataConTy, int8RepDataConTy
94 , wordRepDataConTy, int64RepDataConTy, word8RepDataConTy, word64RepDataConTy
95 , addrRepDataConTy
96 , floatRepDataConTy, doubleRepDataConTy
97 , vec2DataConTy, vec4DataConTy, vec8DataConTy, vec16DataConTy, vec32DataConTy
98 , vec64DataConTy
99 , int8ElemRepDataConTy, int16ElemRepDataConTy, int32ElemRepDataConTy
100 , int64ElemRepDataConTy, word8ElemRepDataConTy, word16ElemRepDataConTy
101 , word32ElemRepDataConTy, word64ElemRepDataConTy, floatElemRepDataConTy
102 , doubleElemRepDataConTy
103 , mkPromotedListTy )
104
105 import Var ( TyVar, VarBndr(Bndr), mkTyVar )
106 import Name
107 import TyCon
108 import SrcLoc
109 import Unique
110 import PrelNames
111 import FastString
112 import Outputable
113 import TyCoRep -- Doesn't need special access, but this is easier to avoid
114 -- import loops which show up if you import Type instead
115
116 import Data.Char
117
118 {-
119 ************************************************************************
120 * *
121 \subsection{Primitive type constructors}
122 * *
123 ************************************************************************
124 -}
125
126 primTyCons :: [TyCon]
127 primTyCons = unexposedPrimTyCons ++ exposedPrimTyCons
128
129 -- | Primitive 'TyCon's that are defined in "GHC.Prim" but not exposed.
130 -- It's important to keep these separate as we don't want users to be able to
131 -- write them (see Trac #15209) or see them in GHCi's @:browse@ output
132 -- (see Trac #12023).
133 unexposedPrimTyCons :: [TyCon]
134 unexposedPrimTyCons
135 = [ eqPrimTyCon
136 , eqReprPrimTyCon
137 , eqPhantPrimTyCon
138 ]
139
140 -- | Primitive 'TyCon's that are defined in, and exported from, "GHC.Prim".
141 exposedPrimTyCons :: [TyCon]
142 exposedPrimTyCons
143 = [ addrPrimTyCon
144 , arrayPrimTyCon
145 , byteArrayPrimTyCon
146 , arrayArrayPrimTyCon
147 , smallArrayPrimTyCon
148 , charPrimTyCon
149 , doublePrimTyCon
150 , floatPrimTyCon
151 , intPrimTyCon
152 , int8PrimTyCon
153 , int32PrimTyCon
154 , int64PrimTyCon
155 , bcoPrimTyCon
156 , weakPrimTyCon
157 , mutableArrayPrimTyCon
158 , mutableByteArrayPrimTyCon
159 , mutableArrayArrayPrimTyCon
160 , smallMutableArrayPrimTyCon
161 , mVarPrimTyCon
162 , tVarPrimTyCon
163 , mutVarPrimTyCon
164 , realWorldTyCon
165 , stablePtrPrimTyCon
166 , stableNamePrimTyCon
167 , compactPrimTyCon
168 , statePrimTyCon
169 , voidPrimTyCon
170 , proxyPrimTyCon
171 , threadIdPrimTyCon
172 , wordPrimTyCon
173 , word8PrimTyCon
174 , word32PrimTyCon
175 , word64PrimTyCon
176
177 , tYPETyCon
178
179 #include "primop-vector-tycons.hs-incl"
180 ]
181
182 mkPrimTc :: FastString -> Unique -> TyCon -> Name
183 mkPrimTc fs unique tycon
184 = mkWiredInName gHC_PRIM (mkTcOccFS fs)
185 unique
186 (ATyCon tycon) -- Relevant TyCon
187 UserSyntax
188
189 mkBuiltInPrimTc :: FastString -> Unique -> TyCon -> Name
190 mkBuiltInPrimTc fs unique tycon
191 = mkWiredInName gHC_PRIM (mkTcOccFS fs)
192 unique
193 (ATyCon tycon) -- Relevant TyCon
194 BuiltInSyntax
195
196
197 charPrimTyConName, intPrimTyConName, int8PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName, voidPrimTyConName :: Name
198 charPrimTyConName = mkPrimTc (fsLit "Char#") charPrimTyConKey charPrimTyCon
199 intPrimTyConName = mkPrimTc (fsLit "Int#") intPrimTyConKey intPrimTyCon
200 int8PrimTyConName = mkPrimTc (fsLit "Int8#") int8PrimTyConKey int8PrimTyCon
201 int32PrimTyConName = mkPrimTc (fsLit "Int32#") int32PrimTyConKey int32PrimTyCon
202 int64PrimTyConName = mkPrimTc (fsLit "Int64#") int64PrimTyConKey int64PrimTyCon
203 wordPrimTyConName = mkPrimTc (fsLit "Word#") wordPrimTyConKey wordPrimTyCon
204 word8PrimTyConName = mkPrimTc (fsLit "Word8#") word8PrimTyConKey word8PrimTyCon
205 word32PrimTyConName = mkPrimTc (fsLit "Word32#") word32PrimTyConKey word32PrimTyCon
206 word64PrimTyConName = mkPrimTc (fsLit "Word64#") word64PrimTyConKey word64PrimTyCon
207 addrPrimTyConName = mkPrimTc (fsLit "Addr#") addrPrimTyConKey addrPrimTyCon
208 floatPrimTyConName = mkPrimTc (fsLit "Float#") floatPrimTyConKey floatPrimTyCon
209 doublePrimTyConName = mkPrimTc (fsLit "Double#") doublePrimTyConKey doublePrimTyCon
210 statePrimTyConName = mkPrimTc (fsLit "State#") statePrimTyConKey statePrimTyCon
211 voidPrimTyConName = mkPrimTc (fsLit "Void#") voidPrimTyConKey voidPrimTyCon
212 proxyPrimTyConName = mkPrimTc (fsLit "Proxy#") proxyPrimTyConKey proxyPrimTyCon
213 eqPrimTyConName = mkPrimTc (fsLit "~#") eqPrimTyConKey eqPrimTyCon
214 eqReprPrimTyConName = mkBuiltInPrimTc (fsLit "~R#") eqReprPrimTyConKey eqReprPrimTyCon
215 eqPhantPrimTyConName = mkBuiltInPrimTc (fsLit "~P#") eqPhantPrimTyConKey eqPhantPrimTyCon
216 realWorldTyConName = mkPrimTc (fsLit "RealWorld") realWorldTyConKey realWorldTyCon
217 arrayPrimTyConName = mkPrimTc (fsLit "Array#") arrayPrimTyConKey arrayPrimTyCon
218 byteArrayPrimTyConName = mkPrimTc (fsLit "ByteArray#") byteArrayPrimTyConKey byteArrayPrimTyCon
219 arrayArrayPrimTyConName = mkPrimTc (fsLit "ArrayArray#") arrayArrayPrimTyConKey arrayArrayPrimTyCon
220 smallArrayPrimTyConName = mkPrimTc (fsLit "SmallArray#") smallArrayPrimTyConKey smallArrayPrimTyCon
221 mutableArrayPrimTyConName = mkPrimTc (fsLit "MutableArray#") mutableArrayPrimTyConKey mutableArrayPrimTyCon
222 mutableByteArrayPrimTyConName = mkPrimTc (fsLit "MutableByteArray#") mutableByteArrayPrimTyConKey mutableByteArrayPrimTyCon
223 mutableArrayArrayPrimTyConName= mkPrimTc (fsLit "MutableArrayArray#") mutableArrayArrayPrimTyConKey mutableArrayArrayPrimTyCon
224 smallMutableArrayPrimTyConName= mkPrimTc (fsLit "SmallMutableArray#") smallMutableArrayPrimTyConKey smallMutableArrayPrimTyCon
225 mutVarPrimTyConName = mkPrimTc (fsLit "MutVar#") mutVarPrimTyConKey mutVarPrimTyCon
226 mVarPrimTyConName = mkPrimTc (fsLit "MVar#") mVarPrimTyConKey mVarPrimTyCon
227 tVarPrimTyConName = mkPrimTc (fsLit "TVar#") tVarPrimTyConKey tVarPrimTyCon
228 stablePtrPrimTyConName = mkPrimTc (fsLit "StablePtr#") stablePtrPrimTyConKey stablePtrPrimTyCon
229 stableNamePrimTyConName = mkPrimTc (fsLit "StableName#") stableNamePrimTyConKey stableNamePrimTyCon
230 compactPrimTyConName = mkPrimTc (fsLit "Compact#") compactPrimTyConKey compactPrimTyCon
231 bcoPrimTyConName = mkPrimTc (fsLit "BCO#") bcoPrimTyConKey bcoPrimTyCon
232 weakPrimTyConName = mkPrimTc (fsLit "Weak#") weakPrimTyConKey weakPrimTyCon
233 threadIdPrimTyConName = mkPrimTc (fsLit "ThreadId#") threadIdPrimTyConKey threadIdPrimTyCon
234
235 {-
236 ************************************************************************
237 * *
238 \subsection{Support code}
239 * *
240 ************************************************************************
241
242 alphaTyVars is a list of type variables for use in templates:
243 ["a", "b", ..., "z", "t1", "t2", ... ]
244 -}
245
246 mkTemplateKindVars :: [Kind] -> [TyVar]
247 -- k0 with unique (mkAlphaTyVarUnique 0)
248 -- k1 with unique (mkAlphaTyVarUnique 1)
249 -- ... etc
250 mkTemplateKindVars kinds
251 = [ mkTyVar name kind
252 | (kind, u) <- kinds `zip` [0..]
253 , let occ = mkTyVarOccFS (mkFastString ('k' : show u))
254 name = mkInternalName (mkAlphaTyVarUnique u) occ noSrcSpan
255 ]
256
257 mkTemplateTyVarsFrom :: Int -> [Kind] -> [TyVar]
258 -- a with unique (mkAlphaTyVarUnique n)
259 -- b with unique (mkAlphaTyVarUnique n+1)
260 -- ... etc
261 -- Typically called as
262 -- mkTemplateTyVarsFrom (length kv_bndrs) kinds
263 -- where kv_bndrs are the kind-level binders of a TyCon
264 mkTemplateTyVarsFrom n kinds
265 = [ mkTyVar name kind
266 | (kind, index) <- zip kinds [0..],
267 let ch_ord = index + ord 'a'
268 name_str | ch_ord <= ord 'z' = [chr ch_ord]
269 | otherwise = 't':show index
270 uniq = mkAlphaTyVarUnique (index + n)
271 name = mkInternalName uniq occ noSrcSpan
272 occ = mkTyVarOccFS (mkFastString name_str)
273 ]
274
275 mkTemplateTyVars :: [Kind] -> [TyVar]
276 mkTemplateTyVars = mkTemplateTyVarsFrom 1
277
278 mkTemplateTyConBinders
279 :: [Kind] -- [k1, .., kn] Kinds of kind-forall'd vars
280 -> ([Kind] -> [Kind]) -- Arg is [kv1:k1, ..., kvn:kn]
281 -- same length as first arg
282 -- Result is anon arg kinds
283 -> [TyConBinder]
284 mkTemplateTyConBinders kind_var_kinds mk_anon_arg_kinds
285 = kv_bndrs ++ tv_bndrs
286 where
287 kv_bndrs = mkTemplateKindTyConBinders kind_var_kinds
288 anon_kinds = mk_anon_arg_kinds (mkTyVarTys (binderVars kv_bndrs))
289 tv_bndrs = mkTemplateAnonTyConBindersFrom (length kv_bndrs) anon_kinds
290
291 mkTemplateKiTyVars
292 :: [Kind] -- [k1, .., kn] Kinds of kind-forall'd vars
293 -> ([Kind] -> [Kind]) -- Arg is [kv1:k1, ..., kvn:kn]
294 -- same length as first arg
295 -- Result is anon arg kinds [ak1, .., akm]
296 -> [TyVar] -- [kv1:k1, ..., kvn:kn, av1:ak1, ..., avm:akm]
297 -- Example: if you want the tyvars for
298 -- forall (r:RuntimeRep) (a:TYPE r) (b:*). blah
299 -- call mkTemplateKiTyVars [RuntimeRep] (\[r]. [TYPE r, *)
300 mkTemplateKiTyVars kind_var_kinds mk_arg_kinds
301 = kv_bndrs ++ tv_bndrs
302 where
303 kv_bndrs = mkTemplateKindVars kind_var_kinds
304 anon_kinds = mk_arg_kinds (mkTyVarTys kv_bndrs)
305 tv_bndrs = mkTemplateTyVarsFrom (length kv_bndrs) anon_kinds
306
307 mkTemplateKindTyConBinders :: [Kind] -> [TyConBinder]
308 -- Makes named, Specified binders
309 mkTemplateKindTyConBinders kinds = [mkNamedTyConBinder Specified tv | tv <- mkTemplateKindVars kinds]
310
311 mkTemplateAnonTyConBinders :: [Kind] -> [TyConBinder]
312 mkTemplateAnonTyConBinders kinds = map mkAnonTyConBinder (mkTemplateTyVars kinds)
313
314 mkTemplateAnonTyConBindersFrom :: Int -> [Kind] -> [TyConBinder]
315 mkTemplateAnonTyConBindersFrom n kinds = map mkAnonTyConBinder (mkTemplateTyVarsFrom n kinds)
316
317 alphaTyVars :: [TyVar]
318 alphaTyVars = mkTemplateTyVars $ repeat liftedTypeKind
319
320 alphaTyVar, betaTyVar, gammaTyVar, deltaTyVar :: TyVar
321 (alphaTyVar:betaTyVar:gammaTyVar:deltaTyVar:_) = alphaTyVars
322
323 alphaTys :: [Type]
324 alphaTys = mkTyVarTys alphaTyVars
325 alphaTy, betaTy, gammaTy, deltaTy :: Type
326 (alphaTy:betaTy:gammaTy:deltaTy:_) = alphaTys
327
328 alphaTyVarsUnliftedRep :: [TyVar]
329 alphaTyVarsUnliftedRep = mkTemplateTyVars $ repeat (tYPE unliftedRepDataConTy)
330
331 alphaTyVarUnliftedRep :: TyVar
332 (alphaTyVarUnliftedRep:_) = alphaTyVarsUnliftedRep
333
334 alphaTysUnliftedRep :: [Type]
335 alphaTysUnliftedRep = mkTyVarTys alphaTyVarsUnliftedRep
336 alphaTyUnliftedRep :: Type
337 (alphaTyUnliftedRep:_) = alphaTysUnliftedRep
338
339 runtimeRep1TyVar, runtimeRep2TyVar :: TyVar
340 (runtimeRep1TyVar : runtimeRep2TyVar : _)
341 = drop 16 (mkTemplateTyVars (repeat runtimeRepTy)) -- selects 'q','r'
342
343 runtimeRep1Ty, runtimeRep2Ty :: Type
344 runtimeRep1Ty = mkTyVarTy runtimeRep1TyVar
345 runtimeRep2Ty = mkTyVarTy runtimeRep2TyVar
346
347 openAlphaTyVar, openBetaTyVar :: TyVar
348 [openAlphaTyVar,openBetaTyVar]
349 = mkTemplateTyVars [tYPE runtimeRep1Ty, tYPE runtimeRep2Ty]
350
351 openAlphaTy, openBetaTy :: Type
352 openAlphaTy = mkTyVarTy openAlphaTyVar
353 openBetaTy = mkTyVarTy openBetaTyVar
354
355 {-
356 ************************************************************************
357 * *
358 FunTyCon
359 * *
360 ************************************************************************
361 -}
362
363 funTyConName :: Name
364 funTyConName = mkPrimTyConName (fsLit "->") funTyConKey funTyCon
365
366 -- | The @(->)@ type constructor.
367 --
368 -- @
369 -- (->) :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep).
370 -- TYPE rep1 -> TYPE rep2 -> *
371 -- @
372 funTyCon :: TyCon
373 funTyCon = mkFunTyCon funTyConName tc_bndrs tc_rep_nm
374 where
375 tc_bndrs = [ Bndr runtimeRep1TyVar (NamedTCB Inferred)
376 , Bndr runtimeRep2TyVar (NamedTCB Inferred)
377 ]
378 ++ mkTemplateAnonTyConBinders [ tYPE runtimeRep1Ty
379 , tYPE runtimeRep2Ty
380 ]
381 tc_rep_nm = mkPrelTyConRepName funTyConName
382
383 {-
384 ************************************************************************
385 * *
386 Kinds
387 * *
388 ************************************************************************
389
390 Note [TYPE and RuntimeRep]
391 ~~~~~~~~~~~~~~~~~~~~~~~~~~
392 All types that classify values have a kind of the form (TYPE rr), where
393
394 data RuntimeRep -- Defined in ghc-prim:GHC.Types
395 = LiftedRep
396 | UnliftedRep
397 | IntRep
398 | FloatRep
399 .. etc ..
400
401 rr :: RuntimeRep
402
403 TYPE :: RuntimeRep -> TYPE 'LiftedRep -- Built in
404
405 So for example:
406 Int :: TYPE 'LiftedRep
407 Array# Int :: TYPE 'UnliftedRep
408 Int# :: TYPE 'IntRep
409 Float# :: TYPE 'FloatRep
410 Maybe :: TYPE 'LiftedRep -> TYPE 'LiftedRep
411 (# , #) :: TYPE r1 -> TYPE r2 -> TYPE (TupleRep [r1, r2])
412
413 We abbreviate '*' specially:
414 type * = TYPE 'LiftedRep
415
416 The 'rr' parameter tells us how the value is represented at runime.
417
418 Generally speaking, you can't be polymorphic in 'rr'. E.g
419 f :: forall (rr:RuntimeRep) (a:TYPE rr). a -> [a]
420 f = /\(rr:RuntimeRep) (a:rr) \(a:rr). ...
421 This is no good: we could not generate code code for 'f', because the
422 calling convention for 'f' varies depending on whether the argument is
423 a a Int, Int#, or Float#. (You could imagine generating specialised
424 code, one for each instantiation of 'rr', but we don't do that.)
425
426 Certain functions CAN be runtime-rep-polymorphic, because the code
427 generator never has to manipulate a value of type 'a :: TYPE rr'.
428
429 * error :: forall (rr:RuntimeRep) (a:TYPE rr). String -> a
430 Code generator never has to manipulate the return value.
431
432 * unsafeCoerce#, defined in MkId.unsafeCoerceId:
433 Always inlined to be a no-op
434 unsafeCoerce# :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep)
435 (a :: TYPE r1) (b :: TYPE r2).
436 a -> b
437
438 * Unboxed tuples, and unboxed sums, defined in TysWiredIn
439 Always inlined, and hence specialised to the call site
440 (#,#) :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep)
441 (a :: TYPE r1) (b :: TYPE r2).
442 a -> b -> TYPE ('TupleRep '[r1, r2])
443
444 Note [PrimRep and kindPrimRep]
445 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
446 As part of its source code, in TyCon, GHC has
447 data PrimRep = LiftedRep | UnliftedRep | IntRep | FloatRep | ...etc...
448
449 Notice that
450 * RuntimeRep is part of the syntax tree of the program being compiled
451 (defined in a library: ghc-prim:GHC.Types)
452 * PrimRep is part of GHC's source code.
453 (defined in TyCon)
454
455 We need to get from one to the other; that is what kindPrimRep does.
456 Suppose we have a value
457 (v :: t) where (t :: k)
458 Given this kind
459 k = TyConApp "TYPE" [rep]
460 GHC needs to be able to figure out how 'v' is represented at runtime.
461 It expects 'rep' to be form
462 TyConApp rr_dc args
463 where 'rr_dc' is a promoteed data constructor from RuntimeRep. So
464 now we need to go from 'dc' to the corresponding PrimRep. We store this
465 PrimRep in the promoted data constructor itself: see TyCon.promDcRepInfo.
466
467 -}
468
469 tYPETyCon :: TyCon
470 tYPETyConName :: Name
471
472 tYPETyCon = mkKindTyCon tYPETyConName
473 (mkTemplateAnonTyConBinders [runtimeRepTy])
474 liftedTypeKind
475 [Nominal]
476 (mkPrelTyConRepName tYPETyConName)
477
478 --------------------------
479 -- ... and now their names
480
481 -- If you edit these, you may need to update the GHC formalism
482 -- See Note [GHC Formalism] in coreSyn/CoreLint.hs
483 tYPETyConName = mkPrimTyConName (fsLit "TYPE") tYPETyConKey tYPETyCon
484
485 mkPrimTyConName :: FastString -> Unique -> TyCon -> Name
486 mkPrimTyConName = mkPrimTcName BuiltInSyntax
487 -- All of the super kinds and kinds are defined in Prim,
488 -- and use BuiltInSyntax, because they are never in scope in the source
489
490 mkPrimTcName :: BuiltInSyntax -> FastString -> Unique -> TyCon -> Name
491 mkPrimTcName built_in_syntax occ key tycon
492 = mkWiredInName gHC_PRIM (mkTcOccFS occ) key (ATyCon tycon) built_in_syntax
493
494 -----------------------------
495 -- | Given a RuntimeRep, applies TYPE to it.
496 -- see Note [TYPE and RuntimeRep]
497 tYPE :: Type -> Type
498 tYPE rr = TyConApp tYPETyCon [rr]
499
500 {-
501 ************************************************************************
502 * *
503 \subsection[TysPrim-basic]{Basic primitive types (@Char#@, @Int#@, etc.)}
504 * *
505 ************************************************************************
506 -}
507
508 -- only used herein
509 pcPrimTyCon :: Name -> [Role] -> PrimRep -> TyCon
510 pcPrimTyCon name roles rep
511 = mkPrimTyCon name binders result_kind roles
512 where
513 binders = mkTemplateAnonTyConBinders (map (const liftedTypeKind) roles)
514 result_kind = tYPE (primRepToRuntimeRep rep)
515
516 -- | Convert a 'PrimRep' to a 'Type' of kind RuntimeRep
517 -- Defined here to avoid (more) module loops
518 primRepToRuntimeRep :: PrimRep -> Type
519 primRepToRuntimeRep rep = case rep of
520 VoidRep -> TyConApp tupleRepDataConTyCon [mkPromotedListTy runtimeRepTy []]
521 LiftedRep -> liftedRepDataConTy
522 UnliftedRep -> unliftedRepDataConTy
523 IntRep -> intRepDataConTy
524 Int8Rep -> int8RepDataConTy
525 WordRep -> wordRepDataConTy
526 Int64Rep -> int64RepDataConTy
527 Word8Rep -> word8RepDataConTy
528 Word64Rep -> word64RepDataConTy
529 AddrRep -> addrRepDataConTy
530 FloatRep -> floatRepDataConTy
531 DoubleRep -> doubleRepDataConTy
532 VecRep n elem -> TyConApp vecRepDataConTyCon [n', elem']
533 where
534 n' = case n of
535 2 -> vec2DataConTy
536 4 -> vec4DataConTy
537 8 -> vec8DataConTy
538 16 -> vec16DataConTy
539 32 -> vec32DataConTy
540 64 -> vec64DataConTy
541 _ -> pprPanic "Disallowed VecCount" (ppr n)
542
543 elem' = case elem of
544 Int8ElemRep -> int8ElemRepDataConTy
545 Int16ElemRep -> int16ElemRepDataConTy
546 Int32ElemRep -> int32ElemRepDataConTy
547 Int64ElemRep -> int64ElemRepDataConTy
548 Word8ElemRep -> word8ElemRepDataConTy
549 Word16ElemRep -> word16ElemRepDataConTy
550 Word32ElemRep -> word32ElemRepDataConTy
551 Word64ElemRep -> word64ElemRepDataConTy
552 FloatElemRep -> floatElemRepDataConTy
553 DoubleElemRep -> doubleElemRepDataConTy
554
555 pcPrimTyCon0 :: Name -> PrimRep -> TyCon
556 pcPrimTyCon0 name rep
557 = pcPrimTyCon name [] rep
558
559 charPrimTy :: Type
560 charPrimTy = mkTyConTy charPrimTyCon
561 charPrimTyCon :: TyCon
562 charPrimTyCon = pcPrimTyCon0 charPrimTyConName WordRep
563
564 intPrimTy :: Type
565 intPrimTy = mkTyConTy intPrimTyCon
566 intPrimTyCon :: TyCon
567 intPrimTyCon = pcPrimTyCon0 intPrimTyConName IntRep
568
569 int8PrimTy :: Type
570 int8PrimTy = mkTyConTy int8PrimTyCon
571 int8PrimTyCon :: TyCon
572 int8PrimTyCon = pcPrimTyCon0 int8PrimTyConName Int8Rep
573
574 int32PrimTy :: Type
575 int32PrimTy = mkTyConTy int32PrimTyCon
576 int32PrimTyCon :: TyCon
577 int32PrimTyCon = pcPrimTyCon0 int32PrimTyConName IntRep
578
579 int64PrimTy :: Type
580 int64PrimTy = mkTyConTy int64PrimTyCon
581 int64PrimTyCon :: TyCon
582 int64PrimTyCon = pcPrimTyCon0 int64PrimTyConName Int64Rep
583
584 wordPrimTy :: Type
585 wordPrimTy = mkTyConTy wordPrimTyCon
586 wordPrimTyCon :: TyCon
587 wordPrimTyCon = pcPrimTyCon0 wordPrimTyConName WordRep
588
589 word8PrimTy :: Type
590 word8PrimTy = mkTyConTy word8PrimTyCon
591 word8PrimTyCon :: TyCon
592 word8PrimTyCon = pcPrimTyCon0 word8PrimTyConName Word8Rep
593
594 word32PrimTy :: Type
595 word32PrimTy = mkTyConTy word32PrimTyCon
596 word32PrimTyCon :: TyCon
597 word32PrimTyCon = pcPrimTyCon0 word32PrimTyConName WordRep
598
599 word64PrimTy :: Type
600 word64PrimTy = mkTyConTy word64PrimTyCon
601 word64PrimTyCon :: TyCon
602 word64PrimTyCon = pcPrimTyCon0 word64PrimTyConName Word64Rep
603
604 addrPrimTy :: Type
605 addrPrimTy = mkTyConTy addrPrimTyCon
606 addrPrimTyCon :: TyCon
607 addrPrimTyCon = pcPrimTyCon0 addrPrimTyConName AddrRep
608
609 floatPrimTy :: Type
610 floatPrimTy = mkTyConTy floatPrimTyCon
611 floatPrimTyCon :: TyCon
612 floatPrimTyCon = pcPrimTyCon0 floatPrimTyConName FloatRep
613
614 doublePrimTy :: Type
615 doublePrimTy = mkTyConTy doublePrimTyCon
616 doublePrimTyCon :: TyCon
617 doublePrimTyCon = pcPrimTyCon0 doublePrimTyConName DoubleRep
618
619 {-
620 ************************************************************************
621 * *
622 \subsection[TysPrim-state]{The @State#@ type (and @_RealWorld@ types)}
623 * *
624 ************************************************************************
625
626 Note [The equality types story]
627 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
628 GHC sports a veritable menagerie of equality types:
629
630 Type or Lifted? Hetero? Role Built in Defining module
631 class? L/U TyCon
632 -----------------------------------------------------------------------------------------
633 ~# T U hetero nominal eqPrimTyCon GHC.Prim
634 ~~ C L hetero nominal heqTyCon GHC.Types
635 ~ C L homo nominal eqTyCon GHC.Types
636 :~: T L homo nominal (not built-in) Data.Type.Equality
637 :~~: T L hetero nominal (not built-in) Data.Type.Equality
638
639 ~R# T U hetero repr eqReprPrimTy GHC.Prim
640 Coercible C L homo repr coercibleTyCon GHC.Types
641 Coercion T L homo repr (not built-in) Data.Type.Coercion
642 ~P# T U hetero phantom eqPhantPrimTyCon GHC.Prim
643
644 Recall that "hetero" means the equality can related types of different
645 kinds. Knowing that (t1 ~# t2) or (t1 ~R# t2) or even that (t1 ~P# t2)
646 also means that (k1 ~# k2), where (t1 :: k1) and (t2 :: k2).
647
648 To produce less confusion for end users, when not dumping and without
649 -fprint-equality-relations, each of these groups is printed as the bottommost
650 listed equality. That is, (~#) and (~~) are both rendered as (~) in
651 error messages, and (~R#) is rendered as Coercible.
652
653 Let's take these one at a time:
654
655 --------------------------
656 (~#) :: forall k1 k2. k1 -> k2 -> #
657 --------------------------
658 This is The Type Of Equality in GHC. It classifies nominal coercions.
659 This type is used in the solver for recording equality constraints.
660 It responds "yes" to Type.isEqPred and classifies as an EqPred in
661 Type.classifyPredType.
662
663 All wanted constraints of this type are built with coercion holes.
664 (See Note [Coercion holes] in TyCoRep.) But see also
665 Note [Deferred errors for coercion holes] in TcErrors to see how
666 equality constraints are deferred.
667
668 Within GHC, ~# is called eqPrimTyCon, and it is defined in TysPrim.
669
670
671 --------------------------
672 (~~) :: forall k1 k2. k1 -> k2 -> Constraint
673 --------------------------
674 This is (almost) an ordinary class, defined as if by
675 class a ~# b => a ~~ b
676 instance a ~# b => a ~~ b
677 Here's what's unusual about it:
678
679 * We can't actually declare it that way because we don't have syntax for ~#.
680 And ~# isn't a constraint, so even if we could write it, it wouldn't kind
681 check.
682
683 * Users cannot write instances of it.
684
685 * It is "naturally coherent". This means that the solver won't hesitate to
686 solve a goal of type (a ~~ b) even if there is, say (Int ~~ c) in the
687 context. (Normally, it waits to learn more, just in case the given
688 influences what happens next.) See Note [Naturally coherent classes]
689 in TcInteract.
690
691 * It always terminates. That is, in the UndecidableInstances checks, we
692 don't worry if a (~~) constraint is too big, as we know that solving
693 equality terminates.
694
695 On the other hand, this behaves just like any class w.r.t. eager superclass
696 unpacking in the solver. So a lifted equality given quickly becomes an unlifted
697 equality given. This is good, because the solver knows all about unlifted
698 equalities. There is some special-casing in TcInteract.matchClassInst to
699 pretend that there is an instance of this class, as we can't write the instance
700 in Haskell.
701
702 Within GHC, ~~ is called heqTyCon, and it is defined in TysWiredIn.
703
704
705 --------------------------
706 (~) :: forall k. k -> k -> Constraint
707 --------------------------
708 This is /exactly/ like (~~), except with a homogeneous kind.
709 It is an almost-ordinary class defined as if by
710 class a ~# b => (a :: k) ~ (b :: k)
711 instance a ~# b => a ~ b
712
713 * All the bullets for (~~) apply
714
715 * In addition (~) is magical syntax, as ~ is a reserved symbol.
716 It cannot be exported or imported.
717
718 Within GHC, ~ is called eqTyCon, and it is defined in TysWiredIn.
719
720 Historical note: prior to July 18 (~) was defined as a
721 more-ordinary class with (~~) as a superclass. But that made it
722 special in different ways; and the extra superclass selections to
723 get from (~) to (~#) via (~~) were tiresome. Now it's defined
724 uniformly with (~~) and Coercible; much nicer.)
725
726
727 --------------------------
728 (:~:) :: forall k. k -> k -> *
729 (:~~:) :: forall k1 k2. k1 -> k2 -> *
730 --------------------------
731 These are perfectly ordinary GADTs, wrapping (~) and (~~) resp.
732 They are not defined within GHC at all.
733
734
735 --------------------------
736 (~R#) :: forall k1 k2. k1 -> k2 -> #
737 --------------------------
738 The is the representational analogue of ~#. This is the type of representational
739 equalities that the solver works on. All wanted constraints of this type are
740 built with coercion holes.
741
742 Within GHC, ~R# is called eqReprPrimTyCon, and it is defined in TysPrim.
743
744
745 --------------------------
746 Coercible :: forall k. k -> k -> Constraint
747 --------------------------
748 This is quite like (~~) in the way it's defined and treated within GHC, but
749 it's homogeneous. Homogeneity helps with type inference (as GHC can solve one
750 kind from the other) and, in my (Richard's) estimation, will be more intuitive
751 for users.
752
753 An alternative design included HCoercible (like (~~)) and Coercible (like (~)).
754 One annoyance was that we want `coerce :: Coercible a b => a -> b`, and
755 we need the type of coerce to be fully wired-in. So the HCoercible/Coercible
756 split required that both types be fully wired-in. Instead of doing this,
757 I just got rid of HCoercible, as I'm not sure who would use it, anyway.
758
759 Within GHC, Coercible is called coercibleTyCon, and it is defined in
760 TysWiredIn.
761
762
763 --------------------------
764 Coercion :: forall k. k -> k -> *
765 --------------------------
766 This is a perfectly ordinary GADT, wrapping Coercible. It is not defined
767 within GHC at all.
768
769
770 --------------------------
771 (~P#) :: forall k1 k2. k1 -> k2 -> #
772 --------------------------
773 This is the phantom analogue of ~# and it is barely used at all.
774 (The solver has no idea about this one.) Here is the motivation:
775
776 data Phant a = MkPhant
777 type role Phant phantom
778
779 Phant <Int, Bool>_P :: Phant Int ~P# Phant Bool
780
781 We just need to have something to put on that last line. You probably
782 don't need to worry about it.
783
784
785
786 Note [The State# TyCon]
787 ~~~~~~~~~~~~~~~~~~~~~~~
788 State# is the primitive, unlifted type of states. It has one type parameter,
789 thus
790 State# RealWorld
791 or
792 State# s
793
794 where s is a type variable. The only purpose of the type parameter is to
795 keep different state threads separate. It is represented by nothing at all.
796
797 The type parameter to State# is intended to keep separate threads separate.
798 Even though this parameter is not used in the definition of State#, it is
799 given role Nominal to enforce its intended use.
800 -}
801
802 mkStatePrimTy :: Type -> Type
803 mkStatePrimTy ty = TyConApp statePrimTyCon [ty]
804
805 statePrimTyCon :: TyCon -- See Note [The State# TyCon]
806 statePrimTyCon = pcPrimTyCon statePrimTyConName [Nominal] VoidRep
807
808 {-
809 RealWorld is deeply magical. It is *primitive*, but it is not
810 *unlifted* (hence ptrArg). We never manipulate values of type
811 RealWorld; it's only used in the type system, to parameterise State#.
812 -}
813
814 realWorldTyCon :: TyCon
815 realWorldTyCon = mkLiftedPrimTyCon realWorldTyConName [] liftedTypeKind []
816 realWorldTy :: Type
817 realWorldTy = mkTyConTy realWorldTyCon
818 realWorldStatePrimTy :: Type
819 realWorldStatePrimTy = mkStatePrimTy realWorldTy -- State# RealWorld
820
821 -- Note: the ``state-pairing'' types are not truly primitive,
822 -- so they are defined in \tr{TysWiredIn.hs}, not here.
823
824
825 voidPrimTy :: Type
826 voidPrimTy = TyConApp voidPrimTyCon []
827
828 voidPrimTyCon :: TyCon
829 voidPrimTyCon = pcPrimTyCon voidPrimTyConName [] VoidRep
830
831 mkProxyPrimTy :: Type -> Type -> Type
832 mkProxyPrimTy k ty = TyConApp proxyPrimTyCon [k, ty]
833
834 proxyPrimTyCon :: TyCon
835 proxyPrimTyCon = mkPrimTyCon proxyPrimTyConName binders res_kind [Nominal,Nominal]
836 where
837 -- Kind: forall k. k -> Void#
838 binders = mkTemplateTyConBinders [liftedTypeKind] (\ks-> ks)
839 res_kind = unboxedTupleKind []
840
841
842 {- *********************************************************************
843 * *
844 Primitive equality constraints
845 See Note [The equality types story]
846 * *
847 ********************************************************************* -}
848
849 eqPrimTyCon :: TyCon -- The representation type for equality predicates
850 -- See Note [The equality types story]
851 eqPrimTyCon = mkPrimTyCon eqPrimTyConName binders res_kind roles
852 where
853 -- Kind :: forall k1 k2. k1 -> k2 -> Void#
854 binders = mkTemplateTyConBinders [liftedTypeKind, liftedTypeKind] (\ks -> ks)
855 res_kind = unboxedTupleKind []
856 roles = [Nominal, Nominal, Nominal, Nominal]
857
858 -- like eqPrimTyCon, but the type for *Representational* coercions
859 -- this should only ever appear as the type of a covar. Its role is
860 -- interpreted in coercionRole
861 eqReprPrimTyCon :: TyCon -- See Note [The equality types story]
862 eqReprPrimTyCon = mkPrimTyCon eqReprPrimTyConName binders res_kind roles
863 where
864 -- Kind :: forall k1 k2. k1 -> k2 -> Void#
865 binders = mkTemplateTyConBinders [liftedTypeKind, liftedTypeKind] (\ks -> ks)
866 res_kind = unboxedTupleKind []
867 roles = [Nominal, Nominal, Representational, Representational]
868
869 -- like eqPrimTyCon, but the type for *Phantom* coercions.
870 -- This is only used to make higher-order equalities. Nothing
871 -- should ever actually have this type!
872 eqPhantPrimTyCon :: TyCon
873 eqPhantPrimTyCon = mkPrimTyCon eqPhantPrimTyConName binders res_kind roles
874 where
875 -- Kind :: forall k1 k2. k1 -> k2 -> Void#
876 binders = mkTemplateTyConBinders [liftedTypeKind, liftedTypeKind] (\ks -> ks)
877 res_kind = unboxedTupleKind []
878 roles = [Nominal, Nominal, Phantom, Phantom]
879
880 {- *********************************************************************
881 * *
882 The primitive array types
883 * *
884 ********************************************************************* -}
885
886 arrayPrimTyCon, mutableArrayPrimTyCon, mutableByteArrayPrimTyCon,
887 byteArrayPrimTyCon, arrayArrayPrimTyCon, mutableArrayArrayPrimTyCon,
888 smallArrayPrimTyCon, smallMutableArrayPrimTyCon :: TyCon
889 arrayPrimTyCon = pcPrimTyCon arrayPrimTyConName [Representational] UnliftedRep
890 mutableArrayPrimTyCon = pcPrimTyCon mutableArrayPrimTyConName [Nominal, Representational] UnliftedRep
891 mutableByteArrayPrimTyCon = pcPrimTyCon mutableByteArrayPrimTyConName [Nominal] UnliftedRep
892 byteArrayPrimTyCon = pcPrimTyCon0 byteArrayPrimTyConName UnliftedRep
893 arrayArrayPrimTyCon = pcPrimTyCon0 arrayArrayPrimTyConName UnliftedRep
894 mutableArrayArrayPrimTyCon = pcPrimTyCon mutableArrayArrayPrimTyConName [Nominal] UnliftedRep
895 smallArrayPrimTyCon = pcPrimTyCon smallArrayPrimTyConName [Representational] UnliftedRep
896 smallMutableArrayPrimTyCon = pcPrimTyCon smallMutableArrayPrimTyConName [Nominal, Representational] UnliftedRep
897
898 mkArrayPrimTy :: Type -> Type
899 mkArrayPrimTy elt = TyConApp arrayPrimTyCon [elt]
900 byteArrayPrimTy :: Type
901 byteArrayPrimTy = mkTyConTy byteArrayPrimTyCon
902 mkArrayArrayPrimTy :: Type
903 mkArrayArrayPrimTy = mkTyConTy arrayArrayPrimTyCon
904 mkSmallArrayPrimTy :: Type -> Type
905 mkSmallArrayPrimTy elt = TyConApp smallArrayPrimTyCon [elt]
906 mkMutableArrayPrimTy :: Type -> Type -> Type
907 mkMutableArrayPrimTy s elt = TyConApp mutableArrayPrimTyCon [s, elt]
908 mkMutableByteArrayPrimTy :: Type -> Type
909 mkMutableByteArrayPrimTy s = TyConApp mutableByteArrayPrimTyCon [s]
910 mkMutableArrayArrayPrimTy :: Type -> Type
911 mkMutableArrayArrayPrimTy s = TyConApp mutableArrayArrayPrimTyCon [s]
912 mkSmallMutableArrayPrimTy :: Type -> Type -> Type
913 mkSmallMutableArrayPrimTy s elt = TyConApp smallMutableArrayPrimTyCon [s, elt]
914
915
916 {- *********************************************************************
917 * *
918 The mutable variable type
919 * *
920 ********************************************************************* -}
921
922 mutVarPrimTyCon :: TyCon
923 mutVarPrimTyCon = pcPrimTyCon mutVarPrimTyConName [Nominal, Representational] UnliftedRep
924
925 mkMutVarPrimTy :: Type -> Type -> Type
926 mkMutVarPrimTy s elt = TyConApp mutVarPrimTyCon [s, elt]
927
928 {-
929 ************************************************************************
930 * *
931 \subsection[TysPrim-synch-var]{The synchronizing variable type}
932 * *
933 ************************************************************************
934 -}
935
936 mVarPrimTyCon :: TyCon
937 mVarPrimTyCon = pcPrimTyCon mVarPrimTyConName [Nominal, Representational] UnliftedRep
938
939 mkMVarPrimTy :: Type -> Type -> Type
940 mkMVarPrimTy s elt = TyConApp mVarPrimTyCon [s, elt]
941
942 {-
943 ************************************************************************
944 * *
945 \subsection[TysPrim-stm-var]{The transactional variable type}
946 * *
947 ************************************************************************
948 -}
949
950 tVarPrimTyCon :: TyCon
951 tVarPrimTyCon = pcPrimTyCon tVarPrimTyConName [Nominal, Representational] UnliftedRep
952
953 mkTVarPrimTy :: Type -> Type -> Type
954 mkTVarPrimTy s elt = TyConApp tVarPrimTyCon [s, elt]
955
956 {-
957 ************************************************************************
958 * *
959 \subsection[TysPrim-stable-ptrs]{The stable-pointer type}
960 * *
961 ************************************************************************
962 -}
963
964 stablePtrPrimTyCon :: TyCon
965 stablePtrPrimTyCon = pcPrimTyCon stablePtrPrimTyConName [Representational] AddrRep
966
967 mkStablePtrPrimTy :: Type -> Type
968 mkStablePtrPrimTy ty = TyConApp stablePtrPrimTyCon [ty]
969
970 {-
971 ************************************************************************
972 * *
973 \subsection[TysPrim-stable-names]{The stable-name type}
974 * *
975 ************************************************************************
976 -}
977
978 stableNamePrimTyCon :: TyCon
979 stableNamePrimTyCon = pcPrimTyCon stableNamePrimTyConName [Phantom] UnliftedRep
980
981 mkStableNamePrimTy :: Type -> Type
982 mkStableNamePrimTy ty = TyConApp stableNamePrimTyCon [ty]
983
984 {-
985 ************************************************************************
986 * *
987 \subsection[TysPrim-compact-nfdata]{The Compact NFData (CNF) type}
988 * *
989 ************************************************************************
990 -}
991
992 compactPrimTyCon :: TyCon
993 compactPrimTyCon = pcPrimTyCon0 compactPrimTyConName UnliftedRep
994
995 compactPrimTy :: Type
996 compactPrimTy = mkTyConTy compactPrimTyCon
997
998 {-
999 ************************************************************************
1000 * *
1001 \subsection[TysPrim-BCOs]{The ``bytecode object'' type}
1002 * *
1003 ************************************************************************
1004 -}
1005
1006 bcoPrimTy :: Type
1007 bcoPrimTy = mkTyConTy bcoPrimTyCon
1008 bcoPrimTyCon :: TyCon
1009 bcoPrimTyCon = pcPrimTyCon0 bcoPrimTyConName UnliftedRep
1010
1011 {-
1012 ************************************************************************
1013 * *
1014 \subsection[TysPrim-Weak]{The ``weak pointer'' type}
1015 * *
1016 ************************************************************************
1017 -}
1018
1019 weakPrimTyCon :: TyCon
1020 weakPrimTyCon = pcPrimTyCon weakPrimTyConName [Representational] UnliftedRep
1021
1022 mkWeakPrimTy :: Type -> Type
1023 mkWeakPrimTy v = TyConApp weakPrimTyCon [v]
1024
1025 {-
1026 ************************************************************************
1027 * *
1028 \subsection[TysPrim-thread-ids]{The ``thread id'' type}
1029 * *
1030 ************************************************************************
1031
1032 A thread id is represented by a pointer to the TSO itself, to ensure
1033 that they are always unique and we can always find the TSO for a given
1034 thread id. However, this has the unfortunate consequence that a
1035 ThreadId# for a given thread is treated as a root by the garbage
1036 collector and can keep TSOs around for too long.
1037
1038 Hence the programmer API for thread manipulation uses a weak pointer
1039 to the thread id internally.
1040 -}
1041
1042 threadIdPrimTy :: Type
1043 threadIdPrimTy = mkTyConTy threadIdPrimTyCon
1044 threadIdPrimTyCon :: TyCon
1045 threadIdPrimTyCon = pcPrimTyCon0 threadIdPrimTyConName UnliftedRep
1046
1047 {-
1048 ************************************************************************
1049 * *
1050 \subsection{SIMD vector types}
1051 * *
1052 ************************************************************************
1053 -}
1054
1055 #include "primop-vector-tys.hs-incl"