1 {- This module really should be auto-generated from the master primops.txt file.
2 It is roughly correct (but may be slightly incomplete) wrt/ GHC5.02. -}
11 initialEnv = efromlist [(primMname,primEnv),
15 primEnv = Envs {tcenv_=efromlist primTcs,
17 cenv_=efromlist primDcs,
18 venv_=efromlist primVals}
21 errorEnv = Envs {tcenv_=eempty,
24 venv_=efromlist errorVals}
26 {- Components of static environment -}
28 primTcs :: [(Tcon,Kind)]
30 map (\ ((m,tc),k) -> (tc,k))
34 (tcDoublezh,ktDoublezh),
35 (tcFloatzh,ktFloatzh),
37 (tcInt32zh,ktInt32zh),
38 (tcInt64zh,ktInt64zh),
40 (tcWord32zh,ktWord32zh),
41 (tcWord64zh,ktWord64zh),
42 (tcRealWorld, ktRealWorld),
43 (tcStatezh, ktStatezh),
44 (tcArrayzh,ktArrayzh),
45 (tcByteArrayzh,ktByteArrayzh),
46 (tcMutableArrayzh,ktMutableArrayzh),
47 (tcMutableByteArrayzh,ktMutableByteArrayzh),
48 (tcMutVarzh,ktMutVarzh),
51 (tcForeignObjzh, ktForeignObjzh),
52 (tcStablePtrzh, ktStablePtrzh),
53 (tcThreadIdzh, ktThreadIdzh),
54 (tcZCTCCallable, ktZCTCCallable),
55 (tcZCTCReturnable, ktZCTCReturnable)]
56 ++ [(tcUtuple n, ktUtuple n) | n <- [1..maxUtuple]])
59 primDcs :: [(Dcon,Ty)]
60 primDcs = map (\ ((m,c),t) -> (c,t))
61 [(dcUtuple n, dcUtupleTy n) | n <- [1..maxUtuple]]
63 primVals :: [(Var,Ty)]
89 dcUtuples :: [(Qual Dcon,Ty)]
90 dcUtuples = map ( \n -> (dcUtuple n, typ n)) [1..100]
91 where typ n = foldr ( \tv t -> Tforall (tv,Kopen) t)
92 (foldr ( \tv t -> tArrow (Tvar tv) t)
93 (tUtuple (map Tvar tvs)) tvs) tvs
94 where tvs = map ( \i -> ("a" ++ (show i))) [1..n]
97 pvz = (qual primMname) . (++ "zh")
100 tcAddrzh = pvz "Addr"
101 tAddrzh = Tcon tcAddrzh
105 ("gtAddrzh",tcompare tAddrzh),
106 ("geAddrzh",tcompare tAddrzh),
107 ("eqAddrzh",tcompare tAddrzh),
108 ("neAddrzh",tcompare tAddrzh),
109 ("ltAddrzh",tcompare tAddrzh),
110 ("leAddrzh",tcompare tAddrzh),
111 ("nullAddrzh", tAddrzh),
112 ("plusAddrzh", tArrow tAddrzh (tArrow tIntzh tAddrzh)),
113 ("minusAddrzh", tArrow tAddrzh (tArrow tAddrzh tIntzh)),
114 ("remAddrzh", tArrow tAddrzh (tArrow tIntzh tIntzh))]
118 tcCharzh = pvz "Char"
119 tCharzh = Tcon tcCharzh
123 ("gtCharzh", tcompare tCharzh),
124 ("geCharzh", tcompare tCharzh),
125 ("eqCharzh", tcompare tCharzh),
126 ("neCharzh", tcompare tCharzh),
127 ("ltCharzh", tcompare tCharzh),
128 ("leCharzh", tcompare tCharzh),
129 ("ordzh", tArrow tCharzh tIntzh)]
134 tcDoublezh = pvz "Double"
135 tDoublezh = Tcon tcDoublezh
136 ktDoublezh = Kunlifted
139 ("zgzhzh", tcompare tDoublezh),
140 ("zgzezhzh", tcompare tDoublezh),
141 ("zezezhzh", tcompare tDoublezh),
142 ("zszezhzh", tcompare tDoublezh),
143 ("zlzhzh", tcompare tDoublezh),
144 ("zlzezhzh", tcompare tDoublezh),
145 ("zpzhzh", tdyadic tDoublezh),
146 ("zmzhzh", tdyadic tDoublezh),
147 ("ztzhzh", tdyadic tDoublezh),
148 ("zszhzh", tdyadic tDoublezh),
149 ("negateDoublezh", tmonadic tDoublezh),
150 ("double2Intzh", tArrow tDoublezh tIntzh),
151 ("double2Floatzh", tArrow tDoublezh tFloatzh),
152 ("expDoublezh", tmonadic tDoublezh),
153 ("logDoublezh", tmonadic tDoublezh),
154 ("sqrtDoublezh", tmonadic tDoublezh),
155 ("sinDoublezh", tmonadic tDoublezh),
156 ("cosDoublezh", tmonadic tDoublezh),
157 ("tanDoublezh", tmonadic tDoublezh),
158 ("asinDoublezh", tmonadic tDoublezh),
159 ("acosDoublezh", tmonadic tDoublezh),
160 ("atanDoublezh", tmonadic tDoublezh),
161 ("sinhDoublezh", tmonadic tDoublezh),
162 ("coshDoublezh", tmonadic tDoublezh),
163 ("tanhDoublezh", tmonadic tDoublezh),
164 ("ztztzhzh", tdyadic tDoublezh),
165 ("decodeDoublezh", tArrow tDoublezh (tUtuple[tIntzh,tIntzh,tByteArrayzh]))]
170 tcFloatzh = pvz "Float"
171 tFloatzh = Tcon tcFloatzh
172 ktFloatzh = Kunlifted
175 ("gtFloatzh", tcompare tFloatzh),
176 ("geFloatzh", tcompare tFloatzh),
177 ("eqFloatzh", tcompare tFloatzh),
178 ("neFloatzh", tcompare tFloatzh),
179 ("ltFloatzh", tcompare tFloatzh),
180 ("leFloatzh", tcompare tFloatzh),
181 ("plusFloatzh", tdyadic tFloatzh),
182 ("minusFloatzh", tdyadic tFloatzh),
183 ("timesFloatzh", tdyadic tFloatzh),
184 ("divideFloatzh", tdyadic tFloatzh),
185 ("negateFloatzh", tmonadic tFloatzh),
186 ("float2Intzh", tArrow tFloatzh tIntzh),
187 ("expFloatzh", tmonadic tFloatzh),
188 ("logFloatzh", tmonadic tFloatzh),
189 ("sqrtFloatzh", tmonadic tFloatzh),
190 ("sinFloatzh", tmonadic tFloatzh),
191 ("cosFloatzh", tmonadic tFloatzh),
192 ("tanFloatzh", tmonadic tFloatzh),
193 ("asinFloatzh", tmonadic tFloatzh),
194 ("acosFloatzh", tmonadic tFloatzh),
195 ("atanFloatzh", tmonadic tFloatzh),
196 ("sinhFloatzh", tmonadic tFloatzh),
197 ("coshFloatzh", tmonadic tFloatzh),
198 ("tanhFloatzh", tmonadic tFloatzh),
199 ("powerFloatzh", tdyadic tFloatzh),
200 ("float2Doublezh", tArrow tFloatzh tDoublezh),
201 ("decodeFloatzh", tArrow tFloatzh (tUtuple[tIntzh,tIntzh,tByteArrayzh]))]
207 tIntzh = Tcon tcIntzh
211 ("zpzh", tdyadic tIntzh),
212 ("zmzh", tdyadic tIntzh),
213 ("ztzh", tdyadic tIntzh),
214 ("quotIntzh", tdyadic tIntzh),
215 ("remIntzh", tdyadic tIntzh),
216 ("gcdIntzh", tdyadic tIntzh),
217 ("negateIntzh", tmonadic tIntzh),
218 ("addIntCzh", tArrow tIntzh (tArrow tIntzh (tUtuple [tIntzh, tIntzh]))),
219 ("subIntCzh", tArrow tIntzh (tArrow tIntzh (tUtuple [tIntzh, tIntzh]))),
220 ("mulIntCzh", tArrow tIntzh (tArrow tIntzh (tUtuple [tIntzh, tIntzh]))),
221 ("zgzh", tcompare tIntzh),
222 ("zgzezh", tcompare tIntzh),
223 ("zezezh", tcompare tIntzh),
224 ("zszezh", tcompare tIntzh),
225 ("zlzh", tcompare tIntzh),
226 ("zlzezh", tcompare tIntzh),
227 ("chrzh", tArrow tIntzh tCharzh),
228 ("int2Wordzh", tArrow tIntzh tWordzh),
229 ("int2Floatzh", tArrow tIntzh tFloatzh),
230 ("int2Doublezh", tArrow tIntzh tDoublezh),
231 ("intToInt32zh", tArrow tIntzh tInt32zh),
232 ("int2Integerzh", tArrow tIntzh tIntegerzhRes),
233 ("iShiftLzh", tdyadic tIntzh),
234 ("iShiftRAzh", tdyadic tIntzh),
235 ("iShiftRLh", tdyadic tIntzh)]
240 tcInt32zh = pvz "Int32"
241 tInt32zh = Tcon tcInt32zh
242 ktInt32zh = Kunlifted
245 ("int32ToIntzh", tArrow tInt32zh tIntzh),
246 ("int32ToIntegerzh", tArrow tInt32zh tIntegerzhRes)]
251 tcInt64zh = pvz "Int64"
252 tInt64zh = Tcon tcInt64zh
253 ktInt64zh = Kunlifted
256 ("int64ToIntegerzh", tArrow tInt64zh tIntegerzhRes)]
260 -- not actuallly a primitive type
261 tIntegerzhRes = tUtuple [tIntzh, tByteArrayzh]
262 tIntegerzhTo t = tArrow tIntzh (tArrow tByteArrayzh t)
263 tdyadicIntegerzh = tIntegerzhTo (tIntegerzhTo tIntegerzhRes)
266 ("plusIntegerzh", tdyadicIntegerzh),
267 ("minusIntegerzh", tdyadicIntegerzh),
268 ("timesIntegerzh", tdyadicIntegerzh),
269 ("gcdIntegerzh", tdyadicIntegerzh),
270 ("gcdIntegerIntzh", tIntegerzhTo (tArrow tIntzh tIntzh)),
271 ("divExactIntegerzh", tdyadicIntegerzh),
272 ("quotIntegerzh", tdyadicIntegerzh),
273 ("remIntegerzh", tdyadicIntegerzh),
274 ("cmpIntegerzh", tIntegerzhTo (tIntegerzhTo tIntzh)),
275 ("cmpIntegerIntzh", tIntegerzhTo (tArrow tIntzh tIntzh)),
276 ("quotRemIntegerzh", tIntegerzhTo (tIntegerzhTo (tUtuple [tIntzh,tByteArrayzh,tIntzh,tByteArrayzh]))),
277 ("divModIntegerzh", tIntegerzhTo (tIntegerzhTo (tUtuple [tIntzh,tByteArrayzh,tIntzh,tByteArrayzh]))),
278 ("integer2Intzh", tIntegerzhTo tIntzh),
279 ("integer2Wordzh", tIntegerzhTo tWordzh),
280 ("integerToInt32zh", tIntegerzhTo tInt32zh),
281 ("integerToWord32zh", tIntegerzhTo tWord32zh),
282 ("integerToInt64zh", tIntegerzhTo tInt64zh),
283 ("integerToWord64zh", tIntegerzhTo tWord64zh),
284 ("andIntegerzh", tdyadicIntegerzh),
285 ("orIntegerzh", tdyadicIntegerzh),
286 ("xorIntegerzh", tdyadicIntegerzh),
287 ("complementIntegerzh", tIntegerzhTo tIntegerzhRes)]
293 tcWordzh = pvz "Word"
294 tWordzh = Tcon tcWordzh
298 ("plusWordzh", tdyadic tWordzh),
299 ("minusWordzh", tdyadic tWordzh),
300 ("timesWordzh", tdyadic tWordzh),
301 ("quotWordzh", tdyadic tWordzh),
302 ("remWordzh", tdyadic tWordzh),
303 ("andzh", tdyadic tWordzh),
304 ("orzh", tdyadic tWordzh),
305 ("xorzh", tdyadic tWordzh),
306 ("notzh", tmonadic tWordzh),
307 ("shiftLzh", tArrow tWordzh (tArrow tIntzh tWordzh)),
308 ("shiftRLzh", tArrow tWordzh (tArrow tIntzh tWordzh)),
309 ("word2Intzh", tArrow tWordzh tIntzh),
310 ("wordToWord32zh", tArrow tWordzh tWord32zh),
311 ("word2Integerzh", tArrow tWordzh tIntegerzhRes),
312 ("gtWordzh", tcompare tWordzh),
313 ("geWordzh", tcompare tWordzh),
314 ("eqWordzh", tcompare tWordzh),
315 ("neWordzh", tcompare tWordzh),
316 ("ltWordzh", tcompare tWordzh),
317 ("leWordzh", tcompare tWordzh)]
321 tcWord32zh = pvz "Word32"
322 tWord32zh = Tcon tcWord32zh
323 ktWord32zh = Kunlifted
326 ("word32ToWordzh", tArrow tWord32zh tWordzh),
327 ("word32ToIntegerzh", tArrow tWord32zh tIntegerzhRes)]
331 tcWord64zh = pvz "Word64"
332 tWord64zh = Tcon tcWord64zh
333 ktWord64zh = Kunlifted
336 ("word64ToIntegerzh", tArrow tWord64zh tIntegerzhRes)]
338 {- Explicitly sized Intzh and Wordzh -}
341 ("narrow8Intzh", tmonadic tIntzh),
342 ("narrow16Intzh", tmonadic tIntzh),
343 ("narrow32Intzh", tmonadic tIntzh),
344 ("narrow8Wordzh", tmonadic tWordzh),
345 ("narrow16Wordzh", tmonadic tWordzh),
346 ("narrow32Wordzh", tmonadic tWordzh)]
350 tcArrayzh = pvz "Array"
351 tArrayzh t = Tapp (Tcon tcArrayzh) t
352 ktArrayzh = Karrow Klifted Kunlifted
354 tcByteArrayzh = pvz "ByteArray"
355 tByteArrayzh = Tcon tcByteArrayzh
356 ktByteArrayzh = Kunlifted
358 tcMutableArrayzh = pvz "MutableArray"
359 tMutableArrayzh s t = Tapp (Tapp (Tcon tcMutableArrayzh) s) t
360 ktMutableArrayzh = Karrow Klifted (Karrow Klifted Kunlifted)
362 tcMutableByteArrayzh = pvz "MutableByteArray"
363 tMutableByteArrayzh s = Tapp (Tcon tcMutableByteArrayzh) s
364 ktMutableByteArrayzh = Karrow Klifted Kunlifted
367 ("newArrayzh", Tforall ("a",Klifted)
368 (Tforall ("s",Klifted)
371 (tArrow (tStatezh (Tvar "s"))
372 (tUtuple [tStatezh (Tvar "s"),tMutableArrayzh (Tvar "s") (Tvar "a")])))))),
373 ("newByteArrayzh", Tforall ("s",Klifted)
375 (tArrow (tStatezh (Tvar "s"))
376 (tUtuple [tStatezh (Tvar "s"),tMutableByteArrayzh (Tvar "s")])))),
377 ("newPinnedByteArrayzh", Tforall ("s",Klifted)
379 (tArrow (tStatezh (Tvar "s"))
380 (tUtuple [tStatezh (Tvar "s"),tMutableByteArrayzh (Tvar "s")])))),
381 ("byteArrayContentszh", tArrow tByteArrayzh tAddrzh),
382 ("indexCharArrayzh", tArrow tByteArrayzh (tArrow tIntzh tCharzh)),
383 ("indexWideCharArrayzh", tArrow tByteArrayzh (tArrow tIntzh tCharzh)),
384 ("indexIntArrayzh", tArrow tByteArrayzh (tArrow tIntzh tIntzh)),
385 ("indexWordArrayzh", tArrow tByteArrayzh (tArrow tIntzh tWordzh)),
386 ("indexAddrArrayzh", tArrow tByteArrayzh (tArrow tIntzh tAddrzh)),
387 ("indexFloatArrayzh", tArrow tByteArrayzh (tArrow tIntzh tFloatzh)),
388 ("indexDoubleArrayzh", tArrow tByteArrayzh (tArrow tIntzh tDoublezh)),
389 ("indexStablePtrArrayzh", Tforall ("a",Klifted) (tArrow tByteArrayzh (tArrow tIntzh (tStablePtrzh (Tvar "a"))))),
390 ("indexInt8Arrayzh", tArrow tByteArrayzh (tArrow tIntzh tIntzh)),
391 ("indexInt16Arrayzh", tArrow tByteArrayzh (tArrow tIntzh tIntzh)),
392 ("indexInt32Arrayzh", tArrow tByteArrayzh (tArrow tIntzh tInt32zh)),
393 ("indexInt64Arrayzh", tArrow tByteArrayzh (tArrow tIntzh tInt64zh)),
394 ("indexWord8Arrayzh", tArrow tByteArrayzh (tArrow tIntzh tWordzh)),
395 ("indexWord16Arrayzh", tArrow tByteArrayzh (tArrow tIntzh tWordzh)),
396 ("indexWord32Arrayzh", tArrow tByteArrayzh (tArrow tIntzh tWord32zh)),
397 ("indexWord64Arrayzh", tArrow tByteArrayzh (tArrow tIntzh tWord64zh)),
398 ("readCharArrayzh", tReadMutableByteArrayzh tCharzh),
399 ("readWideCharArrayzh", tReadMutableByteArrayzh tCharzh),
400 ("readIntArrayzh", tReadMutableByteArrayzh tIntzh),
401 ("readWordArrayzh", tReadMutableByteArrayzh tWordzh),
402 ("readAddrArrayzh", tReadMutableByteArrayzh tAddrzh),
403 ("readFloatArrayzh", tReadMutableByteArrayzh tFloatzh),
404 ("readDoubleArrayzh", tReadMutableByteArrayzh tDoublezh),
405 ("readStablePtrArrayzh", Tforall ("s",Klifted)
406 (Tforall ("a",Klifted)
407 (tArrow (tMutableByteArrayzh (Tvar "s"))
409 (tArrow (tStatezh (Tvar "s"))
410 (tUtuple [tStatezh (Tvar "s"),tStablePtrzh (Tvar "a")])))))),
411 ("readInt8Arrayzh", tReadMutableByteArrayzh tIntzh),
412 ("readInt16Arrayzh", tReadMutableByteArrayzh tIntzh),
413 ("readInt32Arrayzh", tReadMutableByteArrayzh tInt32zh),
414 ("readInt64Arrayzh", tReadMutableByteArrayzh tInt64zh),
415 ("readWord8Arrayzh", tReadMutableByteArrayzh tWordzh),
416 ("readWord16Arrayzh", tReadMutableByteArrayzh tWordzh),
417 ("readWord32Arrayzh", tReadMutableByteArrayzh tWord32zh),
418 ("readWord64Arrayzh", tReadMutableByteArrayzh tWord64zh),
420 ("writeCharArrayzh", tWriteMutableByteArrayzh tCharzh),
421 ("writeWideCharArrayzh", tWriteMutableByteArrayzh tCharzh),
422 ("writeIntArrayzh", tWriteMutableByteArrayzh tIntzh),
423 ("writeWordArrayzh", tWriteMutableByteArrayzh tWordzh),
424 ("writeAddrArrayzh", tWriteMutableByteArrayzh tAddrzh),
425 ("writeFloatArrayzh", tWriteMutableByteArrayzh tFloatzh),
426 ("writeDoubleArrayzh", tWriteMutableByteArrayzh tDoublezh),
427 ("writeStablePtrArrayzh", Tforall ("s",Klifted)
428 (Tforall ("a",Klifted)
429 (tArrow (tMutableByteArrayzh (Tvar "s"))
431 (tArrow (tStablePtrzh (Tvar "a"))
432 (tArrow (tStatezh (Tvar "s"))
433 (tStatezh (Tvar "s")))))))),
434 ("writeInt8Arrayzh", tWriteMutableByteArrayzh tIntzh),
435 ("writeInt16Arrayzh", tWriteMutableByteArrayzh tIntzh),
436 ("writeInt32Arrayzh", tWriteMutableByteArrayzh tIntzh),
437 ("writeInt64Arrayzh", tWriteMutableByteArrayzh tInt64zh),
438 ("writeWord8Arrayzh", tWriteMutableByteArrayzh tWordzh),
439 ("writeWord16Arrayzh", tWriteMutableByteArrayzh tWordzh),
440 ("writeWord32Arrayzh", tWriteMutableByteArrayzh tWord32zh),
441 ("writeWord64Arrayzh", tWriteMutableByteArrayzh tWord64zh),
443 ("indexCharOffAddrzh", tArrow tAddrzh (tArrow tIntzh tCharzh)),
444 ("indexWideCharOffAddrzh", tArrow tAddrzh (tArrow tIntzh tCharzh)),
445 ("indexIntOffAddrzh", tArrow tAddrzh (tArrow tIntzh tIntzh)),
446 ("indexWordOffAddrzh", tArrow tAddrzh (tArrow tIntzh tWordzh)),
447 ("indexAddrOffAddrzh", tArrow tAddrzh (tArrow tIntzh tAddrzh)),
448 ("indexFloatOffAddrzh", tArrow tAddrzh (tArrow tIntzh tFloatzh)),
449 ("indexDoubleOffAddrzh", tArrow tAddrzh (tArrow tIntzh tDoublezh)),
450 ("indexStablePtrOffAddrzh", Tforall ("a",Klifted) (tArrow tAddrzh (tArrow tIntzh (tStablePtrzh (Tvar "a"))))),
451 ("indexInt8OffAddrzh", tArrow tAddrzh (tArrow tIntzh tIntzh)),
452 ("indexInt16OffAddrzh", tArrow tAddrzh (tArrow tIntzh tIntzh)),
453 ("indexInt32OffAddrzh", tArrow tAddrzh (tArrow tIntzh tInt32zh)),
454 ("indexInt64OffAddrzh", tArrow tAddrzh (tArrow tIntzh tInt64zh)),
455 ("indexWord8OffAddrzh", tArrow tAddrzh (tArrow tIntzh tWordzh)),
456 ("indexWord16OffAddrzh", tArrow tAddrzh (tArrow tIntzh tWordzh)),
457 ("indexWord32ffAddrzh", tArrow tAddrzh (tArrow tIntzh tWord32zh)),
458 ("indexWord64OffAddrzh", tArrow tAddrzh (tArrow tIntzh tWord64zh)),
460 ("indexCharOffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tCharzh)),
461 ("indexWideCharOffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tCharzh)),
462 ("indexIntOffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tIntzh)),
463 ("indexWordOffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tWordzh)),
464 ("indexAddrOffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tAddrzh)),
465 ("indexFloatOffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tFloatzh)),
466 ("indexDoubleOffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tDoublezh)),
467 ("indexStablePtrOffForeignObjzh", Tforall ("a",Klifted) (tArrow tForeignObjzh (tArrow tIntzh (tStablePtrzh (Tvar "a"))))),
468 ("indexInt8OffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tIntzh)),
469 ("indexInt16OffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tIntzh)),
470 ("indexInt32OffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tInt32zh)),
471 ("indexInt64OffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tInt64zh)),
472 ("indexWord8OffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tWordzh)),
473 ("indexWord16OffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tWordzh)),
474 ("indexWord32ffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tWord32zh)),
475 ("indexWord64OffForeignObjzh", tArrow tForeignObjzh (tArrow tIntzh tWord64zh)),
477 ("readCharOffAddrzh", tReadOffAddrzh tCharzh),
478 ("readWideCharOffAddrzh", tReadOffAddrzh tCharzh),
479 ("readIntOffAddrzh", tReadOffAddrzh tIntzh),
480 ("readWordOffAddrzh", tReadOffAddrzh tWordzh),
481 ("readAddrOffAddrzh", tReadOffAddrzh tAddrzh),
482 ("readFloatOffAddrzh", tReadOffAddrzh tFloatzh),
483 ("readDoubleOffAddrzh", tReadOffAddrzh tDoublezh),
484 ("readStablePtrOffAddrzh", Tforall ("s",Klifted)
485 (Tforall ("a",Klifted)
488 (tArrow (tStatezh (Tvar "s"))
489 (tUtuple [tStatezh (Tvar "s"),tStablePtrzh (Tvar "a")])))))),
490 ("readInt8OffAddrzh", tReadOffAddrzh tIntzh),
491 ("readInt16OffAddrzh", tReadOffAddrzh tIntzh),
492 ("readInt32OffAddrzh", tReadOffAddrzh tInt32zh),
493 ("readInt64OffAddrzh", tReadOffAddrzh tInt64zh),
494 ("readWord8OffAddrzh", tReadOffAddrzh tWordzh),
495 ("readWord16OffAddrzh", tReadOffAddrzh tWordzh),
496 ("readWord32OffAddrzh", tReadOffAddrzh tWord32zh),
497 ("readWord64OffAddrzh", tReadOffAddrzh tWord64zh),
499 ("writeCharOffAddrzh", tWriteOffAddrzh tCharzh),
500 ("writeWideCharOffAddrzh", tWriteOffAddrzh tCharzh),
501 ("writeIntOffAddrzh", tWriteOffAddrzh tIntzh),
502 ("writeWordOffAddrzh", tWriteOffAddrzh tWordzh),
503 ("writeAddrOffAddrzh", tWriteOffAddrzh tAddrzh),
504 ("writeFloatOffAddrzh", tWriteOffAddrzh tFloatzh),
505 ("writeDoubleOffAddrzh", tWriteOffAddrzh tDoublezh),
506 ("writeStablePtrOffAddrzh", Tforall ("a",Klifted) (tWriteOffAddrzh (tStablePtrzh (Tvar "a")))),
507 ("writeInt8OffAddrzh", tWriteOffAddrzh tIntzh),
508 ("writeInt16OffAddrzh", tWriteOffAddrzh tIntzh),
509 ("writeInt32OffAddrzh", tWriteOffAddrzh tInt32zh),
510 ("writeInt64OffAddrzh", tWriteOffAddrzh tInt64zh),
511 ("writeWord8OffAddrzh", tWriteOffAddrzh tWordzh),
512 ("writeWord16OffAddrzh", tWriteOffAddrzh tWordzh),
513 ("writeWord32OffAddrzh", tWriteOffAddrzh tWord32zh),
514 ("writeWord64OffAddrzh", tWriteOffAddrzh tWord64zh),
516 ("sameMutableArrayzh", Tforall ("s",Klifted)
517 (Tforall ("a",Klifted)
518 (tArrow (tMutableArrayzh (Tvar "s") (Tvar "a"))
519 (tArrow (tMutableArrayzh (Tvar "s") (Tvar "a"))
521 ("sameMutableByteArrayzh", Tforall ("s",Klifted)
522 (tArrow (tMutableByteArrayzh (Tvar "s"))
523 (tArrow (tMutableByteArrayzh (Tvar "s"))
525 ("readArrayzh",Tforall ("s",Klifted)
526 (Tforall ("a",Klifted)
527 (tArrow (tMutableArrayzh (Tvar "s") (Tvar "a"))
529 (tArrow (tStatezh (Tvar "s"))
530 (tUtuple[tStatezh (Tvar "s"), Tvar "a"])))))),
531 ("writeArrayzh",Tforall ("s",Klifted)
532 (Tforall ("a",Klifted)
533 (tArrow (tMutableArrayzh (Tvar "s") (Tvar "a"))
536 (tArrow (tStatezh (Tvar "s"))
537 (tStatezh (Tvar "s")))))))),
538 ("indexArrayzh", Tforall ("a",Klifted)
539 (tArrow (tArrayzh (Tvar "a"))
541 (tUtuple[Tvar "a"])))),
542 ("unsafeFreezzeArrayzh",Tforall ("s",Klifted)
543 (Tforall ("a",Klifted)
544 (tArrow (tMutableArrayzh (Tvar "s") (Tvar "a"))
545 (tArrow (tStatezh (Tvar "s"))
546 (tUtuple[tStatezh (Tvar "s"),tArrayzh (Tvar "a")]))))),
547 ("unsafeFreezzeByteArrayzh",Tforall ("s",Klifted)
548 (tArrow (tMutableByteArrayzh (Tvar "s"))
549 (tArrow (tStatezh (Tvar "s"))
550 (tUtuple[tStatezh (Tvar "s"),tByteArrayzh])))),
551 ("unsafeThawArrayzh",Tforall ("a",Klifted)
552 (Tforall ("s",Klifted)
553 (tArrow (tArrayzh (Tvar "a"))
554 (tArrow (tStatezh (Tvar "s"))
555 (tUtuple[tStatezh (Tvar "s"),tMutableArrayzh (Tvar "s") (Tvar "a")]))))),
556 ("sizzeofByteArrayzh", tArrow tByteArrayzh tIntzh),
557 ("sizzeofMutableByteArrayzh", Tforall ("s",Klifted) (tArrow (tMutableByteArrayzh (Tvar "s")) tIntzh))]
559 tReadMutableByteArrayzh t =
560 Tforall ("s",Klifted)
561 (tArrow (tMutableByteArrayzh (Tvar "s"))
563 (tArrow (tStatezh (Tvar "s"))
564 (tUtuple [tStatezh (Tvar "s"),t]))))
566 tWriteMutableByteArrayzh t =
567 Tforall ("s",Klifted)
568 (tArrow (tMutableByteArrayzh (Tvar "s"))
571 (tArrow (tStatezh (Tvar "s"))
572 (tStatezh (Tvar "s"))))))
575 Tforall ("s",Klifted)
578 (tArrow (tStatezh (Tvar "s"))
579 (tUtuple [tStatezh (Tvar "s"),t]))))
583 Tforall ("s",Klifted)
587 (tArrow (tStatezh (Tvar "s"))
588 (tStatezh (Tvar "s"))))))
592 tcMutVarzh = pvz "MutVar"
593 tMutVarzh s t = Tapp (Tapp (Tcon tcMutVarzh) s) t
594 ktMutVarzh = Karrow Klifted (Karrow Klifted Kunlifted)
597 ("newMutVarzh", Tforall ("a",Klifted)
598 (Tforall ("s",Klifted)
599 (tArrow (Tvar "a") (tArrow (tStatezh (Tvar "s"))
600 (tUtuple [tStatezh (Tvar "s"),
601 tMutVarzh (Tvar "s") (Tvar "a")]))))),
602 ("readMutVarzh", Tforall ("s",Klifted)
603 (Tforall ("a",Klifted)
604 (tArrow (tMutVarzh (Tvar "s")(Tvar "a"))
605 (tArrow (tStatezh (Tvar "s"))
606 (tUtuple [tStatezh (Tvar "s"), Tvar "a"]))))),
607 ("writeMutVarzh", Tforall ("s",Klifted)
608 (Tforall ("a",Klifted)
609 (tArrow (tMutVarzh (Tvar "s") (Tvar "a"))
611 (tArrow (tStatezh (Tvar "s"))
612 (tStatezh (Tvar "s"))))))),
613 ("sameMutVarzh", Tforall ("s",Klifted)
614 (Tforall ("a",Klifted)
615 (tArrow (tMutVarzh (Tvar "s") (Tvar "a"))
616 (tArrow (tMutVarzh (Tvar "s") (Tvar "a"))
619 {- Real world and state. -}
621 -- tjc: why isn't this one unboxed?
622 tcRealWorld = pv "RealWorld"
623 tRealWorld = Tcon tcRealWorld
624 ktRealWorld = Klifted
626 tcStatezh = pvz "State"
627 tStatezh t = Tapp (Tcon tcStatezh) t
628 ktStatezh = Karrow Klifted Kunlifted
630 tRWS = tStatezh tRealWorld
633 ("realWorldzh", tRWS)]
640 let t' = tArrow tRWS (tUtuple [tRWS, Tvar "a"]) in
641 Tforall ("a",Klifted)
642 (Tforall ("b",Klifted)
644 (tArrow (tArrow (Tvar "b") t')
646 ("raisezh", Tforall ("a",Klifted)
647 (Tforall ("b",Klifted)
648 (tArrow (Tvar "a") (Tvar "b")))),
649 ("blockAsyncExceptionszh", Tforall ("a",Klifted)
650 (tArrow (tArrow tRWS (tUtuple[tRWS,Tvar "a"]))
651 (tArrow tRWS (tUtuple[tRWS,Tvar "a"])))),
652 ("unblockAsyncExceptionszh", Tforall ("a",Klifted)
653 (tArrow (tArrow tRWS (tUtuple[tRWS,Tvar "a"]))
654 (tArrow tRWS (tUtuple[tRWS,Tvar "a"]))))]
658 tcMVarzh = pvz "MVar"
659 tMVarzh s t = Tapp (Tapp (Tcon tcMVarzh) s) t
660 ktMVarzh = Karrow Klifted (Karrow Klifted Kunlifted)
663 ("newMVarzh", Tforall ("s",Klifted)
664 (Tforall ("a",Klifted)
665 (tArrow (tStatezh (Tvar "s"))
666 (tUtuple[tStatezh (Tvar "s"),tMVarzh (Tvar "s") (Tvar "a")])))),
667 ("takeMVarzh", Tforall ("s",Klifted)
668 (Tforall ("a",Klifted)
669 (tArrow (tMVarzh (Tvar "s") (Tvar "a"))
670 (tArrow (tStatezh (Tvar "s"))
671 (tUtuple[tStatezh (Tvar "s"),Tvar "a"]))))),
672 ("tryTakeMVarzh", Tforall ("s",Klifted)
673 (Tforall ("a",Klifted)
674 (tArrow (tMVarzh (Tvar "s") (Tvar "a"))
675 (tArrow (tStatezh (Tvar "s"))
676 (tUtuple[tStatezh (Tvar "s"),tIntzh,Tvar "a"]))))),
677 ("putMVarzh", Tforall ("s",Klifted)
678 (Tforall ("a",Klifted)
679 (tArrow (tMVarzh (Tvar "s") (Tvar "a"))
681 (tArrow (tStatezh (Tvar "s"))
682 (tStatezh (Tvar "s"))))))),
683 ("tryPutMVarzh", Tforall ("s",Klifted)
684 (Tforall ("a",Klifted)
685 (tArrow (tMVarzh (Tvar "s") (Tvar "a"))
687 (tArrow (tStatezh (Tvar "s"))
688 (tUtuple [tStatezh (Tvar "s"), tIntzh])))))),
689 ("sameMVarzh", Tforall ("s",Klifted)
690 (Tforall ("a",Klifted)
691 (tArrow (tMVarzh (Tvar "s") (Tvar "a"))
692 (tArrow (tMVarzh (Tvar "s") (Tvar "a"))
694 ("isEmptyMVarzh", Tforall ("s",Klifted)
695 (Tforall ("a",Klifted)
696 (tArrow (tMVarzh (Tvar "s") (Tvar "a"))
697 (tArrow (tStatezh (Tvar "s"))
698 (tUtuple[tStatezh (Tvar "s"),tIntzh])))))]
703 tcWeakzh = pvz "Weak"
704 tWeakzh t = Tapp (Tcon tcWeakzh) t
705 ktWeakzh = Karrow Klifted Kunlifted
708 ("mkWeakzh", Tforall ("o",Kopen)
709 (Tforall ("b",Klifted)
710 (Tforall ("c",Klifted)
714 (tArrow tRWS (tUtuple[tRWS, tWeakzh (Tvar "b")])))))))),
715 ("deRefWeakzh", Tforall ("a",Klifted)
716 (tArrow (tWeakzh (Tvar "a"))
717 (tArrow tRWS (tUtuple[tRWS, tIntzh, Tvar "a"])))),
718 ("finalizeWeakzh", Tforall ("a",Klifted)
719 (tArrow (tWeakzh (Tvar "a"))
721 (tUtuple[tRWS,tIntzh,
722 tArrow tRWS (tUtuple[tRWS, tUnit])]))))]
725 {- Foreign Objects -}
727 tcForeignObjzh = pvz "ForeignObj"
728 tForeignObjzh = Tcon tcForeignObjzh
729 ktForeignObjzh = Kunlifted
732 ("mkForeignObjzh", tArrow tAddrzh
733 (tArrow tRWS (tUtuple [tRWS,tForeignObjzh]))),
734 ("writeForeignObjzh", Tforall ("s",Klifted)
735 (tArrow tForeignObjzh
737 (tArrow (tStatezh (Tvar "s")) (tStatezh (Tvar "s")))))),
738 ("foreignObjToAddrzh", tArrow tForeignObjzh tAddrzh),
739 ("touchzh", Tforall ("o",Kopen)
741 (tArrow tRWS tRWS)))]
744 {- Stable Pointers (but not names) -}
746 tcStablePtrzh = pvz "StablePtr"
747 tStablePtrzh t = Tapp (Tcon tcStablePtrzh) t
748 ktStablePtrzh = Karrow Klifted Kunlifted
751 ("makeStablePtrzh", Tforall ("a",Klifted)
753 (tArrow tRWS (tUtuple[tRWS,tStablePtrzh (Tvar "a")])))),
754 ("deRefStablePtrzh", Tforall ("a",Klifted)
755 (tArrow (tStablePtrzh (Tvar "a"))
756 (tArrow tRWS (tUtuple[tRWS,Tvar "a"])))),
757 ("eqStablePtrzh", Tforall ("a",Klifted)
758 (tArrow (tStablePtrzh (Tvar "a"))
759 (tArrow (tStablePtrzh (Tvar "a")) tIntzh)))]
761 {- Concurrency operations -}
763 tcThreadIdzh = pvz "ThreadId"
764 tThreadIdzh = Tcon tcThreadIdzh
765 ktThreadIdzh = Kunlifted
768 ("seqzh", Tforall ("a",Klifted)
769 (tArrow (Tvar "a") tIntzh)),
770 ("parzh", Tforall ("a",Klifted)
771 (tArrow (Tvar "a") tIntzh)),
772 ("delayzh", Tforall ("s",Klifted)
773 (tArrow tIntzh (tArrow (tStatezh (Tvar "s")) (tStatezh (Tvar "s"))))),
774 ("waitReadzh", Tforall ("s",Klifted)
775 (tArrow tIntzh (tArrow (tStatezh (Tvar "s")) (tStatezh (Tvar "s"))))),
776 ("waitWritezh", Tforall ("s",Klifted)
777 (tArrow tIntzh (tArrow (tStatezh (Tvar "s")) (tStatezh (Tvar "s"))))),
778 ("forkzh", Tforall ("a",Klifted)
780 (tArrow tRWS (tUtuple[tRWS,tThreadIdzh])))),
781 ("killThreadzh", Tforall ("a",Klifted)
784 (tArrow tRWS tRWS)))),
785 ("yieldzh", tArrow tRWS tRWS),
786 ("myThreadIdzh", tArrow tRWS (tUtuple[tRWS, tThreadIdzh]))]
788 {- Miscellaneous operations -}
791 ("dataToTagzh", Tforall ("a",Klifted)
792 (tArrow (Tvar "a") tIntzh)),
793 ("tagToEnumzh", Tforall ("a",Klifted)
794 (tArrow tIntzh (Tvar "a"))),
795 ("unsafeCoercezh", Tforall ("a",Kopen)
797 (tArrow (Tvar "a") (Tvar "b")))) -- maybe unneeded
800 {- CCallable and CReturnable.
801 We just define the type constructors for the dictionaries
802 corresponding to these pseudo-classes. -}
804 tcZCTCCallable = pv "ZCTCCallable"
805 ktZCTCCallable = Karrow Kopen Klifted -- ??
806 tcZCTCReturnable = pv "ZCTCReturnable"
807 ktZCTCReturnable = Karrow Kopen Klifted -- ??
809 {- Non-primitive, but mentioned in the types of primitives. -}
820 {- Properly defined in PrelError, but needed in many modules before that. -}
822 ("error", Tforall ("a",Kopen) (tArrow tString (Tvar "a"))),
823 ("irrefutPatError", Tforall ("a",Kopen) (tArrow tString (Tvar "a"))),
824 ("patError", Tforall ("a",Kopen) (tArrow tString (Tvar "a")))]
830 tList t = Tapp (Tcon tcList) t
831 ktList = Karrow Klifted Klifted
832 tString = tList tChar
834 {- Utilities for building types -}
835 tmonadic t = tArrow t t
836 tdyadic t = tArrow t (tArrow t t)
837 tcompare t = tArrow t (tArrow t tBool)