Add kind equalities to GHC.
[ghc.git] / compiler / prelude / TysWiredIn.hs
1 {-
2 (c) The GRASP Project, Glasgow University, 1994-1998
3
4 \section[TysWiredIn]{Wired-in knowledge about {\em non-primitive} types}
5 -}
6
7 {-# LANGUAGE CPP #-}
8
9 -- | This module is about types that can be defined in Haskell, but which
10 -- must be wired into the compiler nonetheless. C.f module TysPrim
11 module TysWiredIn (
12 -- * All wired in things
13 wiredInTyCons, isBuiltInOcc_maybe,
14
15 -- * Bool
16 boolTy, boolTyCon, boolTyCon_RDR, boolTyConName,
17 trueDataCon, trueDataConId, true_RDR,
18 falseDataCon, falseDataConId, false_RDR,
19 promotedFalseDataCon, promotedTrueDataCon,
20
21 -- * Ordering
22 orderingTyCon,
23 ltDataCon, ltDataConId,
24 eqDataCon, eqDataConId,
25 gtDataCon, gtDataConId,
26 promotedLTDataCon, promotedEQDataCon, promotedGTDataCon,
27
28 -- * Char
29 charTyCon, charDataCon, charTyCon_RDR,
30 charTy, stringTy, charTyConName,
31
32 -- * Double
33 doubleTyCon, doubleDataCon, doubleTy, doubleTyConName,
34
35 -- * Float
36 floatTyCon, floatDataCon, floatTy, floatTyConName,
37
38 -- * Int
39 intTyCon, intDataCon, intTyCon_RDR, intDataCon_RDR, intTyConName,
40 intTy,
41
42 -- * Word
43 wordTyCon, wordDataCon, wordTyConName, wordTy,
44
45 -- * Word8
46 word8TyCon, word8DataCon, word8TyConName, word8Ty,
47
48 -- * List
49 listTyCon, listTyCon_RDR, listTyConName, listTyConKey,
50 nilDataCon, nilDataConName, nilDataConKey,
51 consDataCon_RDR, consDataCon, consDataConName,
52
53 mkListTy,
54
55 -- * Maybe
56 maybeTyCon, maybeTyConName,
57 nothingDataCon, nothingDataConName, justDataCon, justDataConName,
58
59 -- * Tuples
60 mkTupleTy, mkBoxedTupleTy,
61 tupleTyCon, tupleDataCon, tupleTyConName,
62 promotedTupleDataCon,
63 unitTyCon, unitDataCon, unitDataConId, unitTy, unitTyConKey,
64 pairTyCon,
65 unboxedUnitTyCon, unboxedUnitDataCon,
66 cTupleTyConName, cTupleTyConNames, isCTupleTyConName,
67
68 -- * Kinds
69 typeNatKindCon, typeNatKind, typeSymbolKindCon, typeSymbolKind,
70 isLiftedTypeKindTyConName, liftedTypeKind, constraintKind,
71 starKindTyConName, unicodeStarKindTyConName,
72 liftedTypeKindTyCon, constraintKindTyCon,
73
74 -- * Parallel arrays
75 mkPArrTy,
76 parrTyCon, parrFakeCon, isPArrTyCon, isPArrFakeCon,
77 parrTyCon_RDR, parrTyConName,
78
79 -- * Equality predicates
80 heqTyCon, heqClass, heqDataCon,
81 coercibleTyCon, coercibleDataCon, coercibleClass,
82
83 -- * Implicit Parameters
84 ipTyCon, ipDataCon, ipClass,
85
86 callStackTyCon,
87
88 mkWiredInTyConName, -- This is used in TcTypeNats to define the
89 -- built-in functions for evaluation.
90
91 mkWiredInIdName, -- used in MkId
92
93 -- * Levity
94 levityTy, levityTyCon, liftedDataCon, unliftedDataCon,
95 liftedPromDataCon, unliftedPromDataCon,
96 liftedDataConTy, unliftedDataConTy,
97 liftedDataConName, unliftedDataConName
98 ) where
99
100 #include "HsVersions.h"
101
102 import {-# SOURCE #-} MkId( mkDataConWorkId, mkDictSelId )
103
104 -- friends:
105 import PrelNames
106 import TysPrim
107
108 -- others:
109 import CoAxiom
110 import Coercion
111 import Id
112 import Constants ( mAX_TUPLE_SIZE, mAX_CTUPLE_SIZE )
113 import Module ( Module )
114 import Type
115 import DataCon
116 import {-# SOURCE #-} ConLike
117 import TyCon
118 import Class ( Class, mkClass )
119 import RdrName
120 import Name
121 import NameSet ( NameSet, mkNameSet, elemNameSet )
122 import BasicTypes ( Arity, RecFlag(..), Boxity(..),
123 TupleSort(..) )
124 import ForeignCall
125 import SrcLoc ( noSrcSpan )
126 import Unique
127 import Data.Array
128 import FastString
129 import Outputable
130 import Util
131 import BooleanFormula ( mkAnd )
132
133 alpha_tyvar :: [TyVar]
134 alpha_tyvar = [alphaTyVar]
135
136 alpha_ty :: [Type]
137 alpha_ty = [alphaTy]
138
139 {-
140 ************************************************************************
141 * *
142 \subsection{Wired in type constructors}
143 * *
144 ************************************************************************
145
146 If you change which things are wired in, make sure you change their
147 names in PrelNames, so they use wTcQual, wDataQual, etc
148 -}
149
150 -- This list is used only to define PrelInfo.wiredInThings. That in turn
151 -- is used to initialise the name environment carried around by the renamer.
152 -- This means that if we look up the name of a TyCon (or its implicit binders)
153 -- that occurs in this list that name will be assigned the wired-in key we
154 -- define here.
155 --
156 -- Because of their infinite nature, this list excludes tuples, Any and implicit
157 -- parameter TyCons. Instead, we have a hack in lookupOrigNameCache to deal with
158 -- these names.
159 --
160 -- See also Note [Known-key names]
161 wiredInTyCons :: [TyCon]
162
163 wiredInTyCons = [ unitTyCon -- Not treated like other tuples, because
164 -- it's defined in GHC.Base, and there's only
165 -- one of it. We put it in wiredInTyCons so
166 -- that it'll pre-populate the name cache, so
167 -- the special case in lookupOrigNameCache
168 -- doesn't need to look out for it
169 , boolTyCon
170 , charTyCon
171 , doubleTyCon
172 , floatTyCon
173 , intTyCon
174 , wordTyCon
175 , word8TyCon
176 , listTyCon
177 , maybeTyCon
178 , parrTyCon
179 , heqTyCon
180 , coercibleTyCon
181 , typeNatKindCon
182 , typeSymbolKindCon
183 , levityTyCon
184 , constraintKindTyCon
185 , liftedTypeKindTyCon
186 , starKindTyCon
187 , unicodeStarKindTyCon
188 , ipTyCon
189 ]
190
191 mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name
192 mkWiredInTyConName built_in modu fs unique tycon
193 = mkWiredInName modu (mkTcOccFS fs) unique
194 (ATyCon tycon) -- Relevant TyCon
195 built_in
196
197 mkWiredInDataConName :: BuiltInSyntax -> Module -> FastString -> Unique -> DataCon -> Name
198 mkWiredInDataConName built_in modu fs unique datacon
199 = mkWiredInName modu (mkDataOccFS fs) unique
200 (AConLike (RealDataCon datacon)) -- Relevant DataCon
201 built_in
202
203 mkWiredInCoAxiomName :: BuiltInSyntax -> Module -> FastString -> Unique
204 -> CoAxiom Branched -> Name
205 mkWiredInCoAxiomName built_in modu fs unique ax
206 = mkWiredInName modu (mkTcOccFS fs) unique
207 (ACoAxiom ax) -- Relevant CoAxiom
208 built_in
209
210 mkWiredInIdName :: Module -> FastString -> Unique -> Id -> Name
211 mkWiredInIdName mod fs uniq id
212 = mkWiredInName mod (mkOccNameFS Name.varName fs) uniq (AnId id) UserSyntax
213
214 -- See Note [Kind-changing of (~) and Coercible]
215 -- in libraries/ghc-prim/GHC/Types.hs
216 heqTyConName, heqDataConName, heqSCSelIdName :: Name
217 heqTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "~~") heqTyConKey heqTyCon
218 heqDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "Eq#") heqDataConKey heqDataCon
219 heqSCSelIdName = mkWiredInIdName gHC_TYPES (fsLit "HEq_sc") heqSCSelIdKey heqSCSelId
220
221 -- See Note [Kind-changing of (~) and Coercible] in libraries/ghc-prim/GHC/Types.hs
222 coercibleTyConName, coercibleDataConName, coercibleSCSelIdName :: Name
223 coercibleTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Coercible") coercibleTyConKey coercibleTyCon
224 coercibleDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "MkCoercible") coercibleDataConKey coercibleDataCon
225 coercibleSCSelIdName = mkWiredInIdName gHC_TYPES (fsLit "Coercible_sc") coercibleSCSelIdKey coercibleSCSelId
226
227 charTyConName, charDataConName, intTyConName, intDataConName :: Name
228 charTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Char") charTyConKey charTyCon
229 charDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "C#") charDataConKey charDataCon
230 intTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Int") intTyConKey intTyCon
231 intDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "I#") intDataConKey intDataCon
232
233 boolTyConName, falseDataConName, trueDataConName :: Name
234 boolTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Bool") boolTyConKey boolTyCon
235 falseDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "False") falseDataConKey falseDataCon
236 trueDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "True") trueDataConKey trueDataCon
237
238 listTyConName, nilDataConName, consDataConName :: Name
239 listTyConName = mkWiredInTyConName BuiltInSyntax gHC_TYPES (fsLit "[]") listTyConKey listTyCon
240 nilDataConName = mkWiredInDataConName BuiltInSyntax gHC_TYPES (fsLit "[]") nilDataConKey nilDataCon
241 consDataConName = mkWiredInDataConName BuiltInSyntax gHC_TYPES (fsLit ":") consDataConKey consDataCon
242
243 maybeTyConName, nothingDataConName, justDataConName :: Name
244 maybeTyConName = mkWiredInTyConName UserSyntax gHC_BASE (fsLit "Maybe")
245 maybeTyConKey maybeTyCon
246 nothingDataConName = mkWiredInDataConName UserSyntax gHC_BASE (fsLit "Nothing")
247 nothingDataConKey nothingDataCon
248 justDataConName = mkWiredInDataConName UserSyntax gHC_BASE (fsLit "Just")
249 justDataConKey justDataCon
250
251 wordTyConName, wordDataConName, word8TyConName, word8DataConName :: Name
252 wordTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Word") wordTyConKey wordTyCon
253 wordDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "W#") wordDataConKey wordDataCon
254 word8TyConName = mkWiredInTyConName UserSyntax gHC_WORD (fsLit "Word8") word8TyConKey word8TyCon
255 word8DataConName = mkWiredInDataConName UserSyntax gHC_WORD (fsLit "W8#") word8DataConKey word8DataCon
256
257 floatTyConName, floatDataConName, doubleTyConName, doubleDataConName :: Name
258 floatTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Float") floatTyConKey floatTyCon
259 floatDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "F#") floatDataConKey floatDataCon
260 doubleTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Double") doubleTyConKey doubleTyCon
261 doubleDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "D#") doubleDataConKey doubleDataCon
262
263 -- Kinds
264 typeNatKindConName, typeSymbolKindConName :: Name
265 typeNatKindConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Nat") typeNatKindConNameKey typeNatKindCon
266 typeSymbolKindConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Symbol") typeSymbolKindConNameKey typeSymbolKindCon
267
268 constraintKindTyConName :: Name
269 constraintKindTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Constraint") constraintKindTyConKey constraintKindTyCon
270
271 liftedTypeKindTyConName, starKindTyConName, unicodeStarKindTyConName
272 :: Name
273 liftedTypeKindTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Type") liftedTypeKindTyConKey liftedTypeKindTyCon
274 starKindTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "*") starKindTyConKey starKindTyCon
275 unicodeStarKindTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "★") unicodeStarKindTyConKey unicodeStarKindTyCon
276
277 levityTyConName, liftedDataConName, unliftedDataConName :: Name
278 levityTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Levity") levityTyConKey levityTyCon
279 liftedDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "Lifted") liftedDataConKey liftedDataCon
280 unliftedDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "Unlifted") unliftedDataConKey unliftedDataCon
281
282 parrTyConName, parrDataConName :: Name
283 parrTyConName = mkWiredInTyConName BuiltInSyntax
284 gHC_PARR' (fsLit "[::]") parrTyConKey parrTyCon
285 parrDataConName = mkWiredInDataConName UserSyntax
286 gHC_PARR' (fsLit "PArr") parrDataConKey parrDataCon
287
288 boolTyCon_RDR, false_RDR, true_RDR, intTyCon_RDR, charTyCon_RDR,
289 intDataCon_RDR, listTyCon_RDR, consDataCon_RDR, parrTyCon_RDR :: RdrName
290 boolTyCon_RDR = nameRdrName boolTyConName
291 false_RDR = nameRdrName falseDataConName
292 true_RDR = nameRdrName trueDataConName
293 intTyCon_RDR = nameRdrName intTyConName
294 charTyCon_RDR = nameRdrName charTyConName
295 intDataCon_RDR = nameRdrName intDataConName
296 listTyCon_RDR = nameRdrName listTyConName
297 consDataCon_RDR = nameRdrName consDataConName
298 parrTyCon_RDR = nameRdrName parrTyConName
299
300 {-
301 ************************************************************************
302 * *
303 \subsection{mkWiredInTyCon}
304 * *
305 ************************************************************************
306 -}
307
308 pcNonRecDataTyCon :: Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
309 -- Not an enumeration
310 pcNonRecDataTyCon = pcTyCon False NonRecursive
311
312 -- This function assumes that the types it creates have all parameters at
313 -- Representational role, and that there is no kind polymorphism.
314 pcTyCon :: Bool -> RecFlag -> Name -> Maybe CType -> [TyVar] -> [DataCon] -> TyCon
315 pcTyCon is_enum is_rec name cType tyvars cons
316 = mkAlgTyCon name
317 (mkFunTys (map tyVarKind tyvars) liftedTypeKind)
318 tyvars
319 (map (const Representational) tyvars)
320 cType
321 [] -- No stupid theta
322 (DataTyCon cons is_enum)
323 (VanillaAlgTyCon (mkPrelTyConRepName name))
324 is_rec
325 False -- Not in GADT syntax
326
327 pcDataCon :: Name -> [TyVar] -> [Type] -> TyCon -> DataCon
328 pcDataCon n univs = pcDataConWithFixity False n univs [] -- no ex_tvs
329
330 pcDataConWithFixity :: Bool -- ^ declared infix?
331 -> Name -- ^ datacon name
332 -> [TyVar] -- ^ univ tyvars
333 -> [TyVar] -- ^ ex tyvars
334 -> [Type] -- ^ args
335 -> TyCon
336 -> DataCon
337 pcDataConWithFixity infx n = pcDataConWithFixity' infx n (incrUnique (nameUnique n))
338 -- The Name's unique is the first of two free uniques;
339 -- the first is used for the datacon itself,
340 -- the second is used for the "worker name"
341 --
342 -- To support this the mkPreludeDataConUnique function "allocates"
343 -- one DataCon unique per pair of Ints.
344
345 pcDataConWithFixity' :: Bool -> Name -> Unique -> [TyVar] -> [TyVar]
346 -> [Type] -> TyCon -> DataCon
347 -- The Name should be in the DataName name space; it's the name
348 -- of the DataCon itself.
349
350 pcDataConWithFixity' declared_infix dc_name wrk_key tyvars ex_tyvars arg_tys tycon
351 = data_con
352 where
353 data_con = mkDataCon dc_name declared_infix prom_info
354 (map (const no_bang) arg_tys)
355 [] -- No labelled fields
356 tyvars
357 ex_tyvars
358 [] -- No equality spec
359 [] -- No theta
360 arg_tys (mkTyConApp tycon (mkTyVarTys tyvars))
361 tycon
362 [] -- No stupid theta
363 (mkDataConWorkId wrk_name data_con)
364 NoDataConRep -- Wired-in types are too simple to need wrappers
365
366 no_bang = HsSrcBang Nothing NoSrcUnpack NoSrcStrict
367
368 modu = ASSERT( isExternalName dc_name )
369 nameModule dc_name
370 dc_occ = nameOccName dc_name
371 wrk_occ = mkDataConWorkerOcc dc_occ
372 wrk_name = mkWiredInName modu wrk_occ wrk_key
373 (AnId (dataConWorkId data_con)) UserSyntax
374
375 prom_info = mkPrelTyConRepName dc_name
376
377 {-
378 ************************************************************************
379 * *
380 Kinds
381 * *
382 ************************************************************************
383 -}
384
385 typeNatKindCon, typeSymbolKindCon :: TyCon
386 -- data Nat
387 -- data Symbol
388 typeNatKindCon = pcTyCon False NonRecursive typeNatKindConName Nothing [] []
389 typeSymbolKindCon = pcTyCon False NonRecursive typeSymbolKindConName Nothing [] []
390
391 typeNatKind, typeSymbolKind :: Kind
392 typeNatKind = mkTyConTy typeNatKindCon
393 typeSymbolKind = mkTyConTy typeSymbolKindCon
394
395 constraintKindTyCon :: TyCon
396 constraintKindTyCon = pcTyCon False NonRecursive constraintKindTyConName
397 Nothing [] []
398
399 liftedTypeKind, constraintKind :: Kind
400 liftedTypeKind = tYPE liftedDataConTy
401 constraintKind = mkTyConApp constraintKindTyCon []
402
403
404 {-
405 ************************************************************************
406 * *
407 Stuff for dealing with tuples
408 * *
409 ************************************************************************
410
411 Note [How tuples work] See also Note [Known-key names] in PrelNames
412 ~~~~~~~~~~~~~~~~~~~~~~
413 * There are three families of tuple TyCons and corresponding
414 DataCons, expressed by the type BasicTypes.TupleSort:
415 data TupleSort = BoxedTuple | UnboxedTuple | ConstraintTuple
416
417 * All three families are AlgTyCons, whose AlgTyConRhs is TupleTyCon
418
419 * BoxedTuples
420 - A wired-in type
421 - Data type declarations in GHC.Tuple
422 - The data constructors really have an info table
423
424 * UnboxedTuples
425 - A wired-in type
426 - Have a pretend DataCon, defined in GHC.Prim,
427 but no actual declaration and no info table
428
429 * ConstraintTuples
430 - Are known-key rather than wired-in. Reason: it's awkward to
431 have all the superclass selectors wired-in.
432 - Declared as classes in GHC.Classes, e.g.
433 class (c1,c2) => (c1,c2)
434 - Given constraints: the superclasses automatically become available
435 - Wanted constraints: there is a built-in instance
436 instance (c1,c2) => (c1,c2)
437 - Currently just go up to 16; beyond that
438 you have to use manual nesting
439 - Their OccNames look like (%,,,%), so they can easily be
440 distinguished from term tuples. But (following Haskell) we
441 pretty-print saturated constraint tuples with round parens; see
442 BasicTypes.tupleParens.
443
444 * In quite a lot of places things are restrcted just to
445 BoxedTuple/UnboxedTuple, and then we used BasicTypes.Boxity to distinguish
446 E.g. tupleTyCon has a Boxity argument
447
448 * When looking up an OccName in the original-name cache
449 (IfaceEnv.lookupOrigNameCache), we spot the tuple OccName to make sure
450 we get the right wired-in name. This guy can't tell the difference
451 betweeen BoxedTuple and ConstraintTuple (same OccName!), so tuples
452 are not serialised into interface files using OccNames at all.
453 -}
454
455 isBuiltInOcc_maybe :: OccName -> Maybe Name
456 -- Built in syntax isn't "in scope" so these OccNames
457 -- map to wired-in Names with BuiltInSyntax
458 isBuiltInOcc_maybe occ
459 = case occNameString occ of
460 "[]" -> choose_ns listTyConName nilDataConName
461 ":" -> Just consDataConName
462 "[::]" -> Just parrTyConName
463 "()" -> tup_name Boxed 0
464 "(##)" -> tup_name Unboxed 0
465 '(':',':rest -> parse_tuple Boxed 2 rest
466 '(':'#':',':rest -> parse_tuple Unboxed 2 rest
467 _other -> Nothing
468 where
469 ns = occNameSpace occ
470
471 parse_tuple sort n rest
472 | (',' : rest2) <- rest = parse_tuple sort (n+1) rest2
473 | tail_matches sort rest = tup_name sort n
474 | otherwise = Nothing
475
476 tail_matches Boxed ")" = True
477 tail_matches Unboxed "#)" = True
478 tail_matches _ _ = False
479
480 tup_name boxity arity
481 = choose_ns (getName (tupleTyCon boxity arity))
482 (getName (tupleDataCon boxity arity))
483
484 choose_ns tc dc
485 | isTcClsNameSpace ns = Just tc
486 | isDataConNameSpace ns = Just dc
487 | otherwise = pprPanic "tup_name" (ppr occ)
488
489 mkTupleOcc :: NameSpace -> Boxity -> Arity -> OccName
490 mkTupleOcc ns sort ar = mkOccName ns str
491 where
492 -- No need to cache these, the caching is done in mk_tuple
493 str = case sort of
494 Unboxed -> '(' : '#' : commas ++ "#)"
495 Boxed -> '(' : commas ++ ")"
496
497 commas = take (ar-1) (repeat ',')
498
499 mkCTupleOcc :: NameSpace -> Arity -> OccName
500 mkCTupleOcc ns ar = mkOccName ns str
501 where
502 str = "(%" ++ commas ++ "%)"
503 commas = take (ar-1) (repeat ',')
504
505 cTupleTyConName :: Arity -> Name
506 cTupleTyConName arity
507 = mkExternalName (mkCTupleTyConUnique arity) gHC_CLASSES
508 (mkCTupleOcc tcName arity) noSrcSpan
509 -- The corresponding DataCon does not have a known-key name
510
511 cTupleTyConNames :: [Name]
512 cTupleTyConNames = map cTupleTyConName (0 : [2..mAX_CTUPLE_SIZE])
513
514 cTupleTyConNameSet :: NameSet
515 cTupleTyConNameSet = mkNameSet cTupleTyConNames
516
517 isCTupleTyConName :: Name -> Bool
518 isCTupleTyConName n
519 = ASSERT2( isExternalName n, ppr n )
520 nameModule n == gHC_CLASSES
521 && n `elemNameSet` cTupleTyConNameSet
522
523 tupleTyCon :: Boxity -> Arity -> TyCon
524 tupleTyCon sort i | i > mAX_TUPLE_SIZE = fst (mk_tuple sort i) -- Build one specially
525 tupleTyCon Boxed i = fst (boxedTupleArr ! i)
526 tupleTyCon Unboxed i = fst (unboxedTupleArr ! i)
527
528 tupleTyConName :: TupleSort -> Arity -> Name
529 tupleTyConName ConstraintTuple a = cTupleTyConName a
530 tupleTyConName BoxedTuple a = tyConName (tupleTyCon Boxed a)
531 tupleTyConName UnboxedTuple a = tyConName (tupleTyCon Unboxed a)
532
533 promotedTupleDataCon :: Boxity -> Arity -> TyCon
534 promotedTupleDataCon boxity i = promoteDataCon (tupleDataCon boxity i)
535
536 tupleDataCon :: Boxity -> Arity -> DataCon
537 tupleDataCon sort i | i > mAX_TUPLE_SIZE = snd (mk_tuple sort i) -- Build one specially
538 tupleDataCon Boxed i = snd (boxedTupleArr ! i)
539 tupleDataCon Unboxed i = snd (unboxedTupleArr ! i)
540
541 boxedTupleArr, unboxedTupleArr :: Array Int (TyCon,DataCon)
542 boxedTupleArr = listArray (0,mAX_TUPLE_SIZE) [mk_tuple Boxed i | i <- [0..mAX_TUPLE_SIZE]]
543 unboxedTupleArr = listArray (0,mAX_TUPLE_SIZE) [mk_tuple Unboxed i | i <- [0..mAX_TUPLE_SIZE]]
544
545 mk_tuple :: Boxity -> Int -> (TyCon,DataCon)
546 mk_tuple boxity arity = (tycon, tuple_con)
547 where
548 tycon = mkTupleTyCon tc_name tc_kind tc_arity tyvars tuple_con
549 tup_sort flavour
550
551 (tup_sort, modu, tc_kind, tc_arity, tyvars, tyvar_tys, flavour)
552 = case boxity of
553 Boxed ->
554 let boxed_tyvars = take arity alphaTyVars in
555 ( BoxedTuple
556 , gHC_TUPLE
557 , mkFunTys (nOfThem arity liftedTypeKind) liftedTypeKind
558 , arity
559 , boxed_tyvars
560 , mkTyVarTys boxed_tyvars
561 , VanillaAlgTyCon (mkPrelTyConRepName tc_name)
562 )
563 -- See Note [Unboxed tuple levity vars] in TyCon
564 Unboxed ->
565 let all_tvs = mkTemplateTyVars (replicate arity levityTy ++
566 map (tYPE . mkTyVarTy) (take arity all_tvs))
567 -- NB: This must be one call to mkTemplateTyVars, to make
568 -- sure that all the uniques are different
569 (lev_tvs, open_tvs) = splitAt arity all_tvs
570 in
571 ( UnboxedTuple
572 , gHC_PRIM
573 , mkInvForAllTys lev_tvs $
574 mkFunTys (map tyVarKind open_tvs) $
575 unliftedTypeKind
576 , arity * 2
577 , all_tvs
578 , mkTyVarTys open_tvs
579 , UnboxedAlgTyCon
580 )
581
582 tc_name = mkWiredInName modu (mkTupleOcc tcName boxity arity) tc_uniq
583 (ATyCon tycon) BuiltInSyntax
584 tuple_con = pcDataCon dc_name tyvars tyvar_tys tycon
585 dc_name = mkWiredInName modu (mkTupleOcc dataName boxity arity) dc_uniq
586 (AConLike (RealDataCon tuple_con)) BuiltInSyntax
587 tc_uniq = mkTupleTyConUnique boxity arity
588 dc_uniq = mkTupleDataConUnique boxity arity
589
590 unitTyCon :: TyCon
591 unitTyCon = tupleTyCon Boxed 0
592
593 unitTyConKey :: Unique
594 unitTyConKey = getUnique unitTyCon
595
596 unitDataCon :: DataCon
597 unitDataCon = head (tyConDataCons unitTyCon)
598
599 unitDataConId :: Id
600 unitDataConId = dataConWorkId unitDataCon
601
602 pairTyCon :: TyCon
603 pairTyCon = tupleTyCon Boxed 2
604
605 unboxedUnitTyCon :: TyCon
606 unboxedUnitTyCon = tupleTyCon Unboxed 0
607
608 unboxedUnitDataCon :: DataCon
609 unboxedUnitDataCon = tupleDataCon Unboxed 0
610
611 {-
612 ************************************************************************
613 * *
614 The ``boxed primitive'' types (@Char@, @Int@, etc)
615 * *
616 ************************************************************************
617 -}
618
619 heqTyCon, coercibleTyCon :: TyCon
620 heqClass, coercibleClass :: Class
621 heqDataCon, coercibleDataCon :: DataCon
622 heqSCSelId, coercibleSCSelId :: Id
623
624 (heqTyCon, heqClass, heqDataCon, heqSCSelId)
625 = (tycon, klass, datacon, sc_sel_id)
626 where
627 tycon = mkClassTyCon heqTyConName kind tvs roles
628 rhs klass NonRecursive
629 (mkSpecialTyConRepName (fsLit "tcHEq") heqTyConName)
630 klass = mkClass tvs [] [sc_pred] [sc_sel_id] [] [] (mkAnd []) tycon
631 datacon = pcDataCon heqDataConName tvs [sc_pred] tycon
632
633 kind = mkInvForAllTys [kv1, kv2] $ mkFunTys [k1, k2] constraintKind
634 kv1:kv2:_ = drop 9 alphaTyVars -- gets "j" and "k"
635 k1 = mkTyVarTy kv1
636 k2 = mkTyVarTy kv2
637 [av,bv] = mkTemplateTyVars [k1, k2]
638 tvs = [kv1, kv2, av, bv]
639 roles = [Nominal, Nominal, Nominal, Nominal]
640 rhs = DataTyCon { data_cons = [datacon], is_enum = False }
641
642 sc_pred = mkTyConApp eqPrimTyCon (mkTyVarTys tvs)
643 sc_sel_id = mkDictSelId heqSCSelIdName klass
644
645 (coercibleTyCon, coercibleClass, coercibleDataCon, coercibleSCSelId)
646 = (tycon, klass, datacon, sc_sel_id)
647 where
648 tycon = mkClassTyCon coercibleTyConName kind tvs roles
649 rhs klass NonRecursive
650 (mkPrelTyConRepName coercibleTyConName)
651 klass = mkClass tvs [] [sc_pred] [sc_sel_id] [] [] (mkAnd []) tycon
652 datacon = pcDataCon coercibleDataConName tvs [sc_pred] tycon
653
654 kind = mkInvForAllTys [kKiVar] $ mkFunTys [k, k] constraintKind
655 k = mkTyVarTy kKiVar
656 [av,bv] = mkTemplateTyVars [k, k]
657 tvs = [kKiVar, av, bv]
658 roles = [Nominal, Representational, Representational]
659 rhs = DataTyCon { data_cons = [datacon], is_enum = False }
660
661 sc_pred = mkTyConApp eqReprPrimTyCon [k, k, mkTyVarTy av, mkTyVarTy bv]
662 sc_sel_id = mkDictSelId coercibleSCSelIdName klass
663
664 -- For information about the usage of the following type, see Note [TYPE]
665 -- in module Kind
666 levityTy :: Type
667 levityTy = mkTyConTy levityTyCon
668
669 levityTyCon :: TyCon
670 levityTyCon = pcTyCon True NonRecursive levityTyConName
671 Nothing [] [liftedDataCon, unliftedDataCon]
672
673 liftedDataCon, unliftedDataCon :: DataCon
674 liftedDataCon = pcDataCon liftedDataConName [] [] levityTyCon
675 unliftedDataCon = pcDataCon unliftedDataConName [] [] levityTyCon
676
677 liftedPromDataCon, unliftedPromDataCon :: TyCon
678 liftedPromDataCon = promoteDataCon liftedDataCon
679 unliftedPromDataCon = promoteDataCon unliftedDataCon
680
681 liftedDataConTy, unliftedDataConTy :: Type
682 liftedDataConTy = mkTyConTy liftedPromDataCon
683 unliftedDataConTy = mkTyConTy unliftedPromDataCon
684
685 liftedTypeKindTyCon, starKindTyCon, unicodeStarKindTyCon :: TyCon
686
687 -- See Note [TYPE] in TysPrim
688 liftedTypeKindTyCon = mkSynonymTyCon liftedTypeKindTyConName
689 liftedTypeKind
690 [] []
691 (tYPE liftedDataConTy)
692
693 starKindTyCon = mkSynonymTyCon starKindTyConName
694 liftedTypeKind
695 [] []
696 (tYPE liftedDataConTy)
697
698 unicodeStarKindTyCon = mkSynonymTyCon unicodeStarKindTyConName
699 liftedTypeKind
700 [] []
701 (tYPE liftedDataConTy)
702
703 charTy :: Type
704 charTy = mkTyConTy charTyCon
705
706 charTyCon :: TyCon
707 charTyCon = pcNonRecDataTyCon charTyConName
708 (Just (CType "" Nothing ("HsChar",fsLit "HsChar")))
709 [] [charDataCon]
710 charDataCon :: DataCon
711 charDataCon = pcDataCon charDataConName [] [charPrimTy] charTyCon
712
713 stringTy :: Type
714 stringTy = mkListTy charTy -- convenience only
715
716 intTy :: Type
717 intTy = mkTyConTy intTyCon
718
719 intTyCon :: TyCon
720 intTyCon = pcNonRecDataTyCon intTyConName
721 (Just (CType "" Nothing ("HsInt",fsLit "HsInt"))) []
722 [intDataCon]
723 intDataCon :: DataCon
724 intDataCon = pcDataCon intDataConName [] [intPrimTy] intTyCon
725
726 wordTy :: Type
727 wordTy = mkTyConTy wordTyCon
728
729 wordTyCon :: TyCon
730 wordTyCon = pcNonRecDataTyCon wordTyConName
731 (Just (CType "" Nothing ("HsWord", fsLit "HsWord"))) []
732 [wordDataCon]
733 wordDataCon :: DataCon
734 wordDataCon = pcDataCon wordDataConName [] [wordPrimTy] wordTyCon
735
736 word8Ty :: Type
737 word8Ty = mkTyConTy word8TyCon
738
739 word8TyCon :: TyCon
740 word8TyCon = pcNonRecDataTyCon word8TyConName
741 (Just (CType "" Nothing ("HsWord8", fsLit "HsWord8"))) []
742 [word8DataCon]
743 word8DataCon :: DataCon
744 word8DataCon = pcDataCon word8DataConName [] [wordPrimTy] word8TyCon
745
746 floatTy :: Type
747 floatTy = mkTyConTy floatTyCon
748
749 floatTyCon :: TyCon
750 floatTyCon = pcNonRecDataTyCon floatTyConName
751 (Just (CType "" Nothing ("HsFloat", fsLit "HsFloat"))) []
752 [floatDataCon]
753 floatDataCon :: DataCon
754 floatDataCon = pcDataCon floatDataConName [] [floatPrimTy] floatTyCon
755
756 doubleTy :: Type
757 doubleTy = mkTyConTy doubleTyCon
758
759 doubleTyCon :: TyCon
760 doubleTyCon = pcNonRecDataTyCon doubleTyConName
761 (Just (CType "" Nothing ("HsDouble",fsLit "HsDouble"))) []
762 [doubleDataCon]
763
764 doubleDataCon :: DataCon
765 doubleDataCon = pcDataCon doubleDataConName [] [doublePrimTy] doubleTyCon
766
767 {-
768 ************************************************************************
769 * *
770 The Bool type
771 * *
772 ************************************************************************
773
774 An ordinary enumeration type, but deeply wired in. There are no
775 magical operations on @Bool@ (just the regular Prelude code).
776
777 {\em BEGIN IDLE SPECULATION BY SIMON}
778
779 This is not the only way to encode @Bool@. A more obvious coding makes
780 @Bool@ just a boxed up version of @Bool#@, like this:
781 \begin{verbatim}
782 type Bool# = Int#
783 data Bool = MkBool Bool#
784 \end{verbatim}
785
786 Unfortunately, this doesn't correspond to what the Report says @Bool@
787 looks like! Furthermore, we get slightly less efficient code (I
788 think) with this coding. @gtInt@ would look like this:
789
790 \begin{verbatim}
791 gtInt :: Int -> Int -> Bool
792 gtInt x y = case x of I# x# ->
793 case y of I# y# ->
794 case (gtIntPrim x# y#) of
795 b# -> MkBool b#
796 \end{verbatim}
797
798 Notice that the result of the @gtIntPrim@ comparison has to be turned
799 into an integer (here called @b#@), and returned in a @MkBool@ box.
800
801 The @if@ expression would compile to this:
802 \begin{verbatim}
803 case (gtInt x y) of
804 MkBool b# -> case b# of { 1# -> e1; 0# -> e2 }
805 \end{verbatim}
806
807 I think this code is a little less efficient than the previous code,
808 but I'm not certain. At all events, corresponding with the Report is
809 important. The interesting thing is that the language is expressive
810 enough to describe more than one alternative; and that a type doesn't
811 necessarily need to be a straightforwardly boxed version of its
812 primitive counterpart.
813
814 {\em END IDLE SPECULATION BY SIMON}
815 -}
816
817 boolTy :: Type
818 boolTy = mkTyConTy boolTyCon
819
820 boolTyCon :: TyCon
821 boolTyCon = pcTyCon True NonRecursive boolTyConName
822 (Just (CType "" Nothing ("HsBool", fsLit "HsBool")))
823 [] [falseDataCon, trueDataCon]
824
825 falseDataCon, trueDataCon :: DataCon
826 falseDataCon = pcDataCon falseDataConName [] [] boolTyCon
827 trueDataCon = pcDataCon trueDataConName [] [] boolTyCon
828
829 falseDataConId, trueDataConId :: Id
830 falseDataConId = dataConWorkId falseDataCon
831 trueDataConId = dataConWorkId trueDataCon
832
833 orderingTyCon :: TyCon
834 orderingTyCon = pcTyCon True NonRecursive orderingTyConName Nothing
835 [] [ltDataCon, eqDataCon, gtDataCon]
836
837 ltDataCon, eqDataCon, gtDataCon :: DataCon
838 ltDataCon = pcDataCon ltDataConName [] [] orderingTyCon
839 eqDataCon = pcDataCon eqDataConName [] [] orderingTyCon
840 gtDataCon = pcDataCon gtDataConName [] [] orderingTyCon
841
842 ltDataConId, eqDataConId, gtDataConId :: Id
843 ltDataConId = dataConWorkId ltDataCon
844 eqDataConId = dataConWorkId eqDataCon
845 gtDataConId = dataConWorkId gtDataCon
846
847 {-
848 ************************************************************************
849 * *
850 The List type
851 Special syntax, deeply wired in,
852 but otherwise an ordinary algebraic data type
853 * *
854 ************************************************************************
855
856 data [] a = [] | a : (List a)
857 -}
858
859 mkListTy :: Type -> Type
860 mkListTy ty = mkTyConApp listTyCon [ty]
861
862 listTyCon :: TyCon
863 listTyCon = buildAlgTyCon listTyConName alpha_tyvar [Representational]
864 Nothing []
865 (DataTyCon [nilDataCon, consDataCon] False )
866 Recursive False
867 (VanillaAlgTyCon (mkSpecialTyConRepName (fsLit "tcList") listTyConName))
868
869 nilDataCon :: DataCon
870 nilDataCon = pcDataCon nilDataConName alpha_tyvar [] listTyCon
871
872 consDataCon :: DataCon
873 consDataCon = pcDataConWithFixity True {- Declared infix -}
874 consDataConName
875 alpha_tyvar [] [alphaTy, mkTyConApp listTyCon alpha_ty] listTyCon
876 -- Interesting: polymorphic recursion would help here.
877 -- We can't use (mkListTy alphaTy) in the defn of consDataCon, else mkListTy
878 -- gets the over-specific type (Type -> Type)
879
880 -- Wired-in type Maybe
881
882 maybeTyCon :: TyCon
883 maybeTyCon = pcTyCon False NonRecursive maybeTyConName Nothing alpha_tyvar
884 [nothingDataCon, justDataCon]
885
886 nothingDataCon :: DataCon
887 nothingDataCon = pcDataCon nothingDataConName alpha_tyvar [] maybeTyCon
888
889 justDataCon :: DataCon
890 justDataCon = pcDataCon justDataConName alpha_tyvar [alphaTy] maybeTyCon
891
892 {-
893 ** *********************************************************************
894 * *
895 The tuple types
896 * *
897 ************************************************************************
898
899 The tuple types are definitely magic, because they form an infinite
900 family.
901
902 \begin{itemize}
903 \item
904 They have a special family of type constructors, of type @TyCon@
905 These contain the tycon arity, but don't require a Unique.
906
907 \item
908 They have a special family of constructors, of type
909 @Id@. Again these contain their arity but don't need a Unique.
910
911 \item
912 There should be a magic way of generating the info tables and
913 entry code for all tuples.
914
915 But at the moment we just compile a Haskell source
916 file\srcloc{lib/prelude/...} containing declarations like:
917 \begin{verbatim}
918 data Tuple0 = Tup0
919 data Tuple2 a b = Tup2 a b
920 data Tuple3 a b c = Tup3 a b c
921 data Tuple4 a b c d = Tup4 a b c d
922 ...
923 \end{verbatim}
924 The print-names associated with the magic @Id@s for tuple constructors
925 ``just happen'' to be the same as those generated by these
926 declarations.
927
928 \item
929 The instance environment should have a magic way to know
930 that each tuple type is an instances of classes @Eq@, @Ix@, @Ord@ and
931 so on. \ToDo{Not implemented yet.}
932
933 \item
934 There should also be a way to generate the appropriate code for each
935 of these instances, but (like the info tables and entry code) it is
936 done by enumeration\srcloc{lib/prelude/InTup?.hs}.
937 \end{itemize}
938 -}
939
940 -- | Make a tuple type. The list of types should /not/ include any
941 -- levity specifications.
942 mkTupleTy :: Boxity -> [Type] -> Type
943 -- Special case for *boxed* 1-tuples, which are represented by the type itself
944 mkTupleTy Boxed [ty] = ty
945 mkTupleTy Boxed tys = mkTyConApp (tupleTyCon Boxed (length tys)) tys
946 mkTupleTy Unboxed tys = mkTyConApp (tupleTyCon Unboxed (length tys))
947 (map (getLevity "mkTupleTy") tys ++ tys)
948
949 -- | Build the type of a small tuple that holds the specified type of thing
950 mkBoxedTupleTy :: [Type] -> Type
951 mkBoxedTupleTy tys = mkTupleTy Boxed tys
952
953 unitTy :: Type
954 unitTy = mkTupleTy Boxed []
955
956
957 {- *********************************************************************
958 * *
959 The parallel-array type, [::]
960 * *
961 ************************************************************************
962
963 Special syntax for parallel arrays needs some wired in definitions.
964 -}
965
966 -- | Construct a type representing the application of the parallel array constructor
967 mkPArrTy :: Type -> Type
968 mkPArrTy ty = mkTyConApp parrTyCon [ty]
969
970 -- | Represents the type constructor of parallel arrays
971 --
972 -- * This must match the definition in @PrelPArr@
973 --
974 -- NB: Although the constructor is given here, it will not be accessible in
975 -- user code as it is not in the environment of any compiled module except
976 -- @PrelPArr@.
977 --
978 parrTyCon :: TyCon
979 parrTyCon = pcNonRecDataTyCon parrTyConName Nothing alpha_tyvar [parrDataCon]
980
981 parrDataCon :: DataCon
982 parrDataCon = pcDataCon
983 parrDataConName
984 alpha_tyvar -- forall'ed type variables
985 [intTy, -- 1st argument: Int
986 mkTyConApp -- 2nd argument: Array# a
987 arrayPrimTyCon
988 alpha_ty]
989 parrTyCon
990
991 -- | Check whether a type constructor is the constructor for parallel arrays
992 isPArrTyCon :: TyCon -> Bool
993 isPArrTyCon tc = tyConName tc == parrTyConName
994
995 -- | Fake array constructors
996 --
997 -- * These constructors are never really used to represent array values;
998 -- however, they are very convenient during desugaring (and, in particular,
999 -- in the pattern matching compiler) to treat array pattern just like
1000 -- yet another constructor pattern
1001 --
1002 parrFakeCon :: Arity -> DataCon
1003 parrFakeCon i | i > mAX_TUPLE_SIZE = mkPArrFakeCon i -- build one specially
1004 parrFakeCon i = parrFakeConArr!i
1005
1006 -- pre-defined set of constructors
1007 --
1008 parrFakeConArr :: Array Int DataCon
1009 parrFakeConArr = array (0, mAX_TUPLE_SIZE) [(i, mkPArrFakeCon i)
1010 | i <- [0..mAX_TUPLE_SIZE]]
1011
1012 -- build a fake parallel array constructor for the given arity
1013 --
1014 mkPArrFakeCon :: Int -> DataCon
1015 mkPArrFakeCon arity = data_con
1016 where
1017 data_con = pcDataCon name [tyvar] tyvarTys parrTyCon
1018 tyvar = head alphaTyVars
1019 tyvarTys = replicate arity $ mkTyVarTy tyvar
1020 nameStr = mkFastString ("MkPArr" ++ show arity)
1021 name = mkWiredInName gHC_PARR' (mkDataOccFS nameStr) unique
1022 (AConLike (RealDataCon data_con)) UserSyntax
1023 unique = mkPArrDataConUnique arity
1024
1025 -- | Checks whether a data constructor is a fake constructor for parallel arrays
1026 isPArrFakeCon :: DataCon -> Bool
1027 isPArrFakeCon dcon = dcon == parrFakeCon (dataConSourceArity dcon)
1028
1029 -- Promoted Booleans
1030
1031 promotedFalseDataCon, promotedTrueDataCon :: TyCon
1032 promotedTrueDataCon = promoteDataCon trueDataCon
1033 promotedFalseDataCon = promoteDataCon falseDataCon
1034
1035 -- Promoted Ordering
1036
1037 promotedLTDataCon
1038 , promotedEQDataCon
1039 , promotedGTDataCon
1040 :: TyCon
1041 promotedLTDataCon = promoteDataCon ltDataCon
1042 promotedEQDataCon = promoteDataCon eqDataCon
1043 promotedGTDataCon = promoteDataCon gtDataCon
1044
1045 {-
1046 Note [The Implicit Parameter class]
1047
1048 Implicit parameters `?x :: a` are desugared into dictionaries for the
1049 class `IP "x" a`, which is defined (in GHC.Classes) as
1050
1051 class IP (x :: Symbol) a | x -> a
1052
1053 This class is wired-in so that `error` and `undefined`, which have
1054 wired-in types, can use the implicit-call-stack feature to provide
1055 a call-stack alongside the error message.
1056 -}
1057
1058 ipDataConName, ipTyConName, ipCoName :: Name
1059 ipDataConName = mkWiredInDataConName UserSyntax gHC_CLASSES (fsLit "IP")
1060 ipDataConKey ipDataCon
1061 ipTyConName = mkWiredInTyConName UserSyntax gHC_CLASSES (fsLit "IP")
1062 ipTyConKey ipTyCon
1063 ipCoName = mkWiredInCoAxiomName BuiltInSyntax gHC_CLASSES (fsLit "NTCo:IP")
1064 ipCoNameKey (toBranchedAxiom ipCoAxiom)
1065
1066 -- See Note [The Implicit Parameter class]
1067 ipTyCon :: TyCon
1068 ipTyCon = mkClassTyCon ipTyConName kind [ip,a] [] rhs ipClass NonRecursive
1069 (mkPrelTyConRepName ipTyConName)
1070 where
1071 kind = mkFunTys [typeSymbolKind, liftedTypeKind] constraintKind
1072 [ip,a] = mkTemplateTyVars [typeSymbolKind, liftedTypeKind]
1073 rhs = NewTyCon ipDataCon (mkTyVarTy a) ([], mkTyVarTy a) ipCoAxiom
1074
1075 ipCoAxiom :: CoAxiom Unbranched
1076 ipCoAxiom = mkNewTypeCo ipCoName ipTyCon [ip,a] [Nominal, Nominal] (mkTyVarTy a)
1077 where
1078 [ip,a] = mkTemplateTyVars [typeSymbolKind, liftedTypeKind]
1079
1080 ipDataCon :: DataCon
1081 ipDataCon = pcDataCon ipDataConName [ip,a] ts ipTyCon
1082 where
1083 [ip,a] = mkTemplateTyVars [typeSymbolKind, liftedTypeKind]
1084 ts = [mkTyVarTy a]
1085
1086 ipClass :: Class
1087 ipClass = mkClass (tyConTyVars ipTyCon) [([ip], [a])] [] [] [] [] (mkAnd [])
1088 ipTyCon
1089 where
1090 [ip, a] = tyConTyVars ipTyCon
1091
1092 -- this is a fake version of the CallStack TyCon so we can refer to it
1093 -- in MkCore.errorTy
1094 callStackTyCon :: TyCon
1095 callStackTyCon = pcNonRecDataTyCon callStackTyConName Nothing [] []