@@ -38,10 +38,10 @@ converts ctxt env x y
39errEnv = map (\(x, b) -> (x, binderTy b))
39errEnv = map (\(x, b) -> (x, binderTy b))
41−isSet :: Context -> Env -> Term -> TC ()
41+isType :: Context -> Env -> Term -> TC ()
42−isSet ctxt env tm = isSet' (normalise ctxt env tm)
42+isType ctxt env tm = isType' (normalise ctxt env tm)
43− where isSet' (Set _) = return ()
43+ where isType' (TType _) = return ()
44− isSet' tm = fail (showEnv env tm ++ " is not a Set")
44+ isType' tm = fail (showEnv env tm ++ " is not a TType")
46recheck :: Context -> Env -> Raw -> Term -> TC (Term, Type, UCs)
46recheck :: Context -> Env -> Raw -> Term -> TC (Term, Type, UCs)
47recheck ctxt env tm orig
47recheck ctxt env tm orig
@@ -87,12 +87,12 @@ check' holes ctxt env top = chk env top where
87 where renameBinders i (Bind x (Pi s) t) = Bind (MN i "binder") (Pi s)
87 where renameBinders i (Bind x (Pi s) t) = Bind (MN i "binder") (Pi s)
88 (renameBinders (i+1) t)
88 (renameBinders (i+1) t)
89 renameBinders i sc = sc
89 renameBinders i sc = sc
90− chk env RSet
90+ chk env RType
91− | holes = return (Set (UVal 0), Set (UVal 0))
91+ | holes = return (TType (UVal 0), TType (UVal 0))
92 | otherwise = do (v, cs) <- get
92 | otherwise = do (v, cs) <- get
93 let c = ULT (UVar v) (UVar (v+1))
93 let c = ULT (UVar v) (UVar (v+1))
94 put (v+2, (c:cs))
94 put (v+2, (c:cs))
95− return (Set (UVar v), Set (UVar (v+1)))
95+ return (TType (UVar v), TType (UVar (v+1)))
96 chk env (RConstant Forgot) = return (Erased, Erased)
96 chk env (RConstant Forgot) = return (Erased, Erased)
97 chk env (RConstant c) = return (Constant c, constType c)
97 chk env (RConstant c) = return (Constant c, constType c)
98 where constType (I _) = Constant IType
98 where constType (I _) = Constant IType
@@ -103,18 +103,18 @@ check' holes ctxt env top = chk env top where
103 constType (W8 _) = Constant W8Type
103 constType (W8 _) = Constant W8Type
104 constType (W16 _) = Constant W16Type
104 constType (W16 _) = Constant W16Type
105 constType Forgot = Erased
105 constType Forgot = Erased
106− constType _ = Set (UVal 0)
106+ constType _ = TType (UVal 0)
107 chk env (RForce t) = do (_, ty) <- chk env t
107 chk env (RForce t) = do (_, ty) <- chk env t
108 return (Erased, ty)
108 return (Erased, ty)
109 chk env (RBind n (Pi s) t)
109 chk env (RBind n (Pi s) t)
110 = do (sv, st) <- chk env s
110 = do (sv, st) <- chk env s
111 (tv, tt) <- chk ((n, Pi sv) : env) t
111 (tv, tt) <- chk ((n, Pi sv) : env) t
112 (v, cs) <- get
112 (v, cs) <- get
113− let Set su = normalise ctxt env st
113+ let TType su = normalise ctxt env st
114− let Set tu = normalise ctxt env tt
114+ let TType tu = normalise ctxt env tt
115 when (not holes) $ put (v+1, ULE su (UVar v):ULE tu (UVar v):cs)
115 when (not holes) $ put (v+1, ULE su (UVar v):ULE tu (UVar v):cs)
116 return (Bind n (Pi (uniqueBinders (map fst env) sv))
116 return (Bind n (Pi (uniqueBinders (map fst env) sv))
117− (pToV n tv), Set (UVar v))
117+ (pToV n tv), TType (UVar v))
118 chk env (RBind n b sc)
118 chk env (RBind n b sc)
119 = do b' <- checkBinder b
119 = do b' <- checkBinder b
120 (scv, sct) <- chk ((n, b'):env) sc
120 (scv, sct) <- chk ((n, b'):env) sc
@@ -123,13 +123,13 @@ check' holes ctxt env top = chk env top where
123 = do (tv, tt) <- chk env t
123 = do (tv, tt) <- chk env t
124 let tv' = normalise ctxt env tv
124 let tv' = normalise ctxt env tv
125 let tt' = normalise ctxt env tt
125 let tt' = normalise ctxt env tt
126− lift $ isSet ctxt env tt'
126+ lift $ isType ctxt env tt'
127 return (Lam tv)
127 return (Lam tv)
128 checkBinder (Pi t)
128 checkBinder (Pi t)
129 = do (tv, tt) <- chk env t
129 = do (tv, tt) <- chk env t
130 let tv' = normalise ctxt env tv
130 let tv' = normalise ctxt env tv
131 let tt' = normalise ctxt env tt
131 let tt' = normalise ctxt env tt
132− lift $ isSet ctxt env tt'
132+ lift $ isType ctxt env tt'
133 return (Pi tv)
133 return (Pi tv)
134 checkBinder (Let t v)
134 checkBinder (Let t v)
135 = do (tv, tt) <- chk env t
135 = do (tv, tt) <- chk env t
@@ -137,7 +137,7 @@ check' holes ctxt env top = chk env top where
137 let tv' = normalise ctxt env tv
137 let tv' = normalise ctxt env tv
138 let tt' = normalise ctxt env tt
138 let tt' = normalise ctxt env tt
139 convertsC ctxt env vt tv
139 convertsC ctxt env vt tv
140− lift $ isSet ctxt env tt'
140+ lift $ isType ctxt env tt'
141 return (Let tv vv)
141 return (Let tv vv)
142 checkBinder (NLet t v)
142 checkBinder (NLet t v)
143 = do (tv, tt) <- chk env t
143 = do (tv, tt) <- chk env t
@@ -145,7 +145,7 @@ check' holes ctxt env top = chk env top where
145 let tv' = normalise ctxt env tv
145 let tv' = normalise ctxt env tv
146 let tt' = normalise ctxt env tt
146 let tt' = normalise ctxt env tt
147 convertsC ctxt env vt tv
147 convertsC ctxt env vt tv
148− lift $ isSet ctxt env tt'
148+ lift $ isType ctxt env tt'
149 return (NLet tv vv)
149 return (NLet tv vv)
150 checkBinder (Hole t)
150 checkBinder (Hole t)
151 | not holes = lift $ tfail (IncompleteTerm undefined)
151 | not holes = lift $ tfail (IncompleteTerm undefined)
@@ -153,13 +153,13 @@ check' holes ctxt env top = chk env top where
153 = do (tv, tt) <- chk env t
153 = do (tv, tt) <- chk env t
154 let tv' = normalise ctxt env tv
154 let tv' = normalise ctxt env tv
155 let tt' = normalise ctxt env tt
155 let tt' = normalise ctxt env tt
156− lift $ isSet ctxt env tt'
156+ lift $ isType ctxt env tt'
157 return (Hole tv)
157 return (Hole tv)
158 checkBinder (GHole t)
158 checkBinder (GHole t)
159 = do (tv, tt) <- chk env t
159 = do (tv, tt) <- chk env t
160 let tv' = normalise ctxt env tv
160 let tv' = normalise ctxt env tv
161 let tt' = normalise ctxt env tt
161 let tt' = normalise ctxt env tt
162− lift $ isSet ctxt env tt'
162+ lift $ isType ctxt env tt'
163 return (GHole tv)
163 return (GHole tv)
164 checkBinder (Guess t v)
164 checkBinder (Guess t v)
165 | not holes = lift $ tfail (IncompleteTerm undefined)
165 | not holes = lift $ tfail (IncompleteTerm undefined)
@@ -169,19 +169,19 @@ check' holes ctxt env top = chk env top where
169 let tv' = normalise ctxt env tv
169 let tv' = normalise ctxt env tv
170 let tt' = normalise ctxt env tt
170 let tt' = normalise ctxt env tt
171 convertsC ctxt env vt tv
171 convertsC ctxt env vt tv
172− lift $ isSet ctxt env tt'
172+ lift $ isType ctxt env tt'
173 return (Guess tv vv)
173 return (Guess tv vv)
174 checkBinder (PVar t)
174 checkBinder (PVar t)
175 = do (tv, tt) <- chk env t
175 = do (tv, tt) <- chk env t
176 let tv' = normalise ctxt env tv
176 let tv' = normalise ctxt env tv
177 let tt' = normalise ctxt env tt
177 let tt' = normalise ctxt env tt
178− lift $ isSet ctxt env tt'
178+ lift $ isType ctxt env tt'
179 return (PVar tv)
179 return (PVar tv)
180 checkBinder (PVTy t)
180 checkBinder (PVTy t)
181 = do (tv, tt) <- chk env t
181 = do (tv, tt) <- chk env t
182 let tv' = normalise ctxt env tv
182 let tv' = normalise ctxt env tv
183 let tt' = normalise ctxt env tt
183 let tt' = normalise ctxt env tt
184− lift $ isSet ctxt env tt'
184+ lift $ isType ctxt env tt'
185 return (PVTy tv)
185 return (PVTy tv)
187 discharge n (Lam t) scv sct
187 discharge n (Lam t) scv sct
@@ -221,17 +221,17 @@ checkProgram :: Context -> RProgram -> TC Context
221checkProgram ctxt [] = return ctxt
221checkProgram ctxt [] = return ctxt
222checkProgram ctxt ((n, RConst t) : xs)
222checkProgram ctxt ((n, RConst t) : xs)
223 = do (t', tt') <- trace (show n) $ check ctxt [] t
223 = do (t', tt') <- trace (show n) $ check ctxt [] t
224− isSet ctxt [] tt'
224+ isType ctxt [] tt'
225 checkProgram (addTyDecl n t' ctxt) xs
225 checkProgram (addTyDecl n t' ctxt) xs
226checkProgram ctxt ((n, RFunction (RawFun ty val)) : xs)
226checkProgram ctxt ((n, RFunction (RawFun ty val)) : xs)
227 = do (ty', tyt') <- trace (show n) $ check ctxt [] ty
227 = do (ty', tyt') <- trace (show n) $ check ctxt [] ty
228 (val', valt') <- check ctxt [] val
228 (val', valt') <- check ctxt [] val
229− isSet ctxt [] tyt'
229+ isType ctxt [] tyt'
230 converts ctxt [] ty' valt'
230 converts ctxt [] ty' valt'
231 checkProgram (addToCtxt n val' ty' ctxt) xs
231 checkProgram (addToCtxt n val' ty' ctxt) xs
232checkProgram ctxt ((n, RData (RDatatype _ ty cons)) : xs)
232checkProgram ctxt ((n, RData (RDatatype _ ty cons)) : xs)
233 = do (ty', tyt') <- trace (show n) $ check ctxt [] ty
233 = do (ty', tyt') <- trace (show n) $ check ctxt [] ty
234− isSet ctxt [] tyt'
234+ isType ctxt [] tyt'
235 -- add the tycon temporarily so we can check constructors
235 -- add the tycon temporarily so we can check constructors
236 let ctxt' = addDatatype (Data n 0 ty' []) ctxt
236 let ctxt' = addDatatype (Data n 0 ty' []) ctxt
237 cons' <- mapM (checkCon ctxt') cons
237 cons' <- mapM (checkCon ctxt') cons