3 {- This module contains a few primitive types that need to be wired in.
4 Most are defined in PrimEnv, which is automatically generated from
7 module Prims(initialEnv, primEnv) where
17 initialEnv = efromlist [(primMname,primEnv),
21 -- Tediously, we add defs for ByteArray# etc. because these are
22 -- declared as ByteArr# (etc.) in primops.txt, and GHC has
23 -- ByteArray# etc. wired-in.
24 -- At least this is better than when all primops were wired-in here.
25 primEnv = Envs {tcenv_=efromlist $ map (\ (t,k) -> (t,Kind k)) $
26 [(snd tcByteArrayzh,ktByteArrayzh),
27 (snd tcMutableArrayzh, ktMutableArrayzh),
28 (snd tcMutableByteArrayzh, ktMutableByteArrayzh)] ++
29 ([(snd $ tcUtuple n, ktUtuple n) | n <- [1..maxUtuple]]
30 ++ ((snd tcArrow,ktArrow):primTcs)),
32 cenv_=efromlist primDcs,
33 venv_=efromlist (opsState ++ primVals)}
36 errorEnv = Envs {tcenv_=eempty,
39 venv_=efromlist errorVals}
42 primDcs :: [(Dcon,Ty)]
43 primDcs = map (\ ((_,c),t) -> (c,t))
44 [(dcUtuple n, dcUtupleTy n) | n <- [1..maxUtuple]]
47 tRWS = tStatezh tRealWorld
49 opsState :: [(Var, Ty)]
51 ("realWorldzh", tRWS)]
55 tcByteArrayzh, tcMutableArrayzh, tcMutableByteArrayzh :: Qual Tcon
56 ktByteArrayzh, ktMutableArrayzh, ktMutableByteArrayzh :: Kind
58 tcByteArrayzh = pvz "ByteArray"
59 ktByteArrayzh = Kunlifted
61 tcMutableArrayzh = pvz "MutableArray"
62 ktMutableArrayzh = Karrow Klifted (Karrow Klifted Kunlifted)
64 tcMutableByteArrayzh = pvz "MutableByteArray"
65 ktMutableByteArrayzh = Karrow Klifted Kunlifted
67 {- Real world and state. -}
69 -- tjc: why isn't this one unboxed?
70 tcRealWorld :: Qual Tcon
71 tcRealWorld = pv "RealWorld"
73 tRealWorld = Tcon tcRealWorld
75 tcStatezh :: Qual Tcon
76 tcStatezh = pvz "State"
78 tStatezh t = Tapp (Tcon tcStatezh) t
80 {- Properly defined in PrelError, but needed in many modules before that. -}
81 errorVals :: [(Var, Ty)]
83 ("error", Tforall ("a",Kopen) (tArrow tString (Tvar "a"))),
84 ("irrefutPatError", str2A),
86 ("divZZeroError", forallAA),
87 ("overflowError", forallAA)]
89 {- Non-primitive, but mentioned in the types of primitives. -}
95 str2A = Tforall ("a",Kopen) (tArrow tAddrzh (Tvar "a"))
96 forallAA = Tforall ("a",Kopen) (Tvar "a")
105 tList t = Tapp (Tcon tcList) t
107 tString = tList tChar