@@ -28,8 +28,12 @@ data ElabInfo = EInfo { params :: [(Name, PTerm)],
29toplevel = EInfo [] emptyContext id
29toplevel = EInfo [] emptyContext id
31+recheckC ctxt env t = do (tm, ty, cs) <- tclift $ recheck ctxt env t
31checkDef ns = do ctxt <- getContext
35checkDef ns = do ctxt <- getContext
32− mapM (\(n, t) -> do (t', _) <- tclift $ recheck ctxt [] t
36+ mapM (\(n, t) -> do (t', _) <- recheckC ctxt [] t
33 return (n, t')) ns
37 return (n, t')) ns
35elabType :: ElabInfo -> SyntaxInfo -> FC -> Name -> PTerm -> Idris ()
39elabType :: ElabInfo -> SyntaxInfo -> FC -> Name -> PTerm -> Idris ()
@@ -41,9 +45,9 @@ elabType info syn fc n ty' = {- let ty' = piBind (params info) ty_in
41 ty' <- implicit syn n ty'
45 ty' <- implicit syn n ty'
42 let ty = addImpl i ty'
46 let ty = addImpl i ty'
43 logLvl 2 $ show n ++ " type " ++ showImp True ty
47 logLvl 2 $ show n ++ " type " ++ showImp True ty
44− ((ty', defer), log) <- tclift $ elaborate ctxt n (Set 0)
48+ ((ty', defer), log) <- tclift $ elaborate ctxt n (Set (UVal 0))
45 (erun fc (build i info False ty))
49 (erun fc (build i info False ty))
46− (cty, _) <- tclift $ recheck ctxt [] ty'
50+ (cty, _) <- recheckC ctxt [] ty'
47 logLvl 2 $ "---> " ++ show cty
51 logLvl 2 $ "---> " ++ show cty
48 let nty = normalise ctxt [] cty
52 let nty = normalise ctxt [] cty
49 ds <- checkDef ((n, nty):defer)
53 ds <- checkDef ((n, nty):defer)
@@ -57,11 +61,11 @@ elabData info syn fc (PDatadecl n t_in dcons)
58 t_in <- implicit syn n t_in
62 t_in <- implicit syn n t_in
59 let t = addImpl i t_in
63 let t = addImpl i t_in
60− ((t', defer), log) <- tclift $ elaborate ctxt n (Set 0)
64+ ((t', defer), log) <- tclift $ elaborate ctxt n (Set (UVal 0))
61 (erun fc (build i info False t))
65 (erun fc (build i info False t))
62 def' <- checkDef defer
66 def' <- checkDef defer
63 addDeferred def'
67 addDeferred def'
64− (cty, _) <- tclift $ recheck ctxt [] t'
68+ (cty, _) <- recheckC ctxt [] t'
65 logLvl 2 $ "---> " ++ show cty
69 logLvl 2 $ "---> " ++ show cty
66 updateContext (addTyDecl n cty) -- temporary, to check cons
70 updateContext (addTyDecl n cty) -- temporary, to check cons
67 cons <- mapM (elabCon info syn) dcons
71 cons <- mapM (elabCon info syn) dcons
@@ -76,13 +80,13 @@ elabCon info syn (n, t_in, fc)
76 t_in <- implicit syn n t_in
80 t_in <- implicit syn n t_in
77 let t = addImpl i t_in
81 let t = addImpl i t_in
78 logLvl 2 $ show fc ++ ":Constructor " ++ show n ++ " : " ++ showImp True t
82 logLvl 2 $ show fc ++ ":Constructor " ++ show n ++ " : " ++ showImp True t
79− ((t', defer), log) <- tclift $ elaborate ctxt n (Set 0)
83+ ((t', defer), log) <- tclift $ elaborate ctxt n (Set (UVal 0))
80 (erun fc (build i info False t))
84 (erun fc (build i info False t))
81 logLvl 2 $ "Rechecking " ++ show t'
85 logLvl 2 $ "Rechecking " ++ show t'
82 def' <- checkDef defer
86 def' <- checkDef defer
83 addDeferred def'
87 addDeferred def'
84 ctxt <- getContext
88 ctxt <- getContext
85− (cty, _) <- tclift $ recheck ctxt [] t'
89+ (cty, _) <- recheckC ctxt [] t'
86 logLvl 2 $ "---> " ++ show n ++ " : " ++ show cty
90 logLvl 2 $ "---> " ++ show n ++ " : " ++ show cty
87 return (n, cty)
91 return (n, cty)
@@ -118,7 +122,7 @@ elabVal info aspat tm_in
118 logLvl 3 ("Value: " ++ show tm')
122 logLvl 3 ("Value: " ++ show tm')
119 let vtm = getInferTerm tm'
123 let vtm = getInferTerm tm'
120 logLvl 2 (show vtm)
124 logLvl 2 (show vtm)
121− tclift $ recheck ctxt [] vtm
125+ recheckC ctxt [] vtm
123elabClause :: ElabInfo -> FC -> PClause -> Idris (Term, Term)
127elabClause :: ElabInfo -> FC -> PClause -> Idris (Term, Term)
124elabClause info fc (PClause fname lhs_in withs rhs_in whereblock)
128elabClause info fc (PClause fname lhs_in withs rhs_in whereblock)
@@ -133,7 +137,7 @@ elabClause info fc (PClause fname lhs_in withs rhs_in whereblock)
133 let lhs_tm = orderPats (getInferTerm lhs')
137 let lhs_tm = orderPats (getInferTerm lhs')
134 let lhs_ty = getInferType lhs'
138 let lhs_ty = getInferType lhs'
135 logLvl 3 (show lhs_tm)
139 logLvl 3 (show lhs_tm)
136− (clhs, clhsty) <- tclift $ recheck ctxt [] lhs_tm
140+ (clhs, clhsty) <- recheckC ctxt [] lhs_tm
137 logLvl 5 ("Checked " ++ show clhs)
141 logLvl 5 ("Checked " ++ show clhs)
138 -- Elaborate where block
142 -- Elaborate where block
139 ist <- getIState
143 ist <- getIState
@@ -163,7 +167,7 @@ elabClause info fc (PClause fname lhs_in withs rhs_in whereblock)
163 def' <- checkDef defer
167 def' <- checkDef defer
164 addDeferred def'
168 addDeferred def'
165 ctxt <- getContext
169 ctxt <- getContext
166− (crhs, crhsty) <- tclift $ recheck ctxt [] rhs'
170+ (crhs, crhsty) <- recheckC ctxt [] rhs'
167 return (clhs, crhs)
171 return (clhs, crhs)
169 decorate x = UN (show fname ++ "#" ++ show x)
173 decorate x = UN (show fname ++ "#" ++ show x)
@@ -193,7 +197,7 @@ elabClause info fc (PWith fname lhs_in withs wval_in withblock)
193 let lhs_ty = getInferType lhs'
197 let lhs_ty = getInferType lhs'
194 let ret_ty = getRetTy lhs_ty
198 let ret_ty = getRetTy lhs_ty
195 logLvl 3 (show lhs_tm)
199 logLvl 3 (show lhs_tm)
196− (clhs, clhsty) <- tclift $ recheck ctxt [] lhs_tm
200+ (clhs, clhsty) <- recheckC ctxt [] lhs_tm
197 logLvl 5 ("Checked " ++ show clhs)
201 logLvl 5 ("Checked " ++ show clhs)
198 let bargs = getPBtys lhs_tm
202 let bargs = getPBtys lhs_tm
199 let wval = addImpl i wval_in
203 let wval = addImpl i wval_in
@@ -210,7 +214,7 @@ elabClause info fc (PWith fname lhs_in withs wval_in withblock)
210 return (tt, d))
214 return (tt, d))
211 def' <- checkDef defer
215 def' <- checkDef defer
212 addDeferred def'
216 addDeferred def'
213− (cwval, cwvalty) <- tclift $ recheck ctxt [] (getInferTerm wval')
217+ (cwval, cwvalty) <- recheckC ctxt [] (getInferTerm wval')
214 logLvl 3 ("With type " ++ show cwvalty ++ "\nRet type " ++ show ret_ty)
218 logLvl 3 ("With type " ++ show cwvalty ++ "\nRet type " ++ show ret_ty)
215 windex <- getName
219 windex <- getName
216 -- build a type declaration for the new function:
220 -- build a type declaration for the new function:
@@ -245,7 +249,7 @@ elabClause info fc (PWith fname lhs_in withs wval_in withblock)
245 return (tt, d))
249 return (tt, d))
246 def' <- checkDef defer
250 def' <- checkDef defer
247 addDeferred def'
251 addDeferred def'
248− (crhs, crhsty) <- tclift $ recheck ctxt [] rhs'
252+ (crhs, crhsty) <- recheckC ctxt [] rhs'
249 return (clhs, crhs)
253 return (clhs, crhs)
251 getImps (Bind n (Pi _) t) = pexp Placeholder : getImps t
255 getImps (Bind n (Pi _) t) = pexp Placeholder : getImps t
@@ -522,7 +526,7 @@ elab ist info pattern tm
522 local f = do e <- get_env
526 local f = do e <- get_env
523 return (f `elem` map fst e)
527 return (f `elem` map fst e)
525− elab' PSet = do fill (RSet 0); solve
529+ elab' PSet = do fill RSet; solve
526 elab' (PConstant c) = do apply (RConstant c) []; solve
530 elab' (PConstant c) = do apply (RConstant c) []; solve
527 elab' (PQuote r) = do fill r; solve
531 elab' (PQuote r) = do fill r; solve
528 elab' (PTrue fc) = try (elab' (PRef fc unitCon))
532 elab' (PTrue fc) = try (elab' (PRef fc unitCon))
@@ -560,7 +564,7 @@ elab ist info pattern tm
560 pexp l, pexp r])
564 pexp l, pexp r])
561 elab' (PRef fc n) | pattern && not (inparamBlock n)
565 elab' (PRef fc n) | pattern && not (inparamBlock n)
562 = do ctxt <- get_context
566 = do ctxt <- get_context
563− let sc = case lookupCtxt n ctxt of
567+ let sc = case lookupTy n ctxt of
564 Nothing -> True
568 Nothing -> True
565 _ -> False
569 _ -> False
@@ -576,7 +580,7 @@ elab ist info pattern tm
576 = do attack; intro (Just n); elabE sc; solve
580 = do attack; intro (Just n); elabE sc; solve
577 elab' (PLam n ty sc)
581 elab' (PLam n ty sc)
578 = do tyn <- unique_hole (MN 0 "lamty")
582 = do tyn <- unique_hole (MN 0 "lamty")
579− claim tyn (RSet 0)
583+ claim tyn RSet
581 introTy (Var tyn) (Just n)
585 introTy (Var tyn) (Just n)
582 -- end_unify
586 -- end_unify
@@ -588,7 +592,7 @@ elab ist info pattern tm
588 = do attack; arg n (MN 0 "ty"); elabE sc; solve
592 = do attack; arg n (MN 0 "ty"); elabE sc; solve
589 elab' (PPi _ n ty sc)
593 elab' (PPi _ n ty sc)
590 = do attack; tyn <- unique_hole (MN 0 "ty")
594 = do attack; tyn <- unique_hole (MN 0 "ty")
591− claim tyn (RSet 0)
595+ claim tyn RSet
592 n' <- case n of
596 n' <- case n of
593 MN _ _ -> unique_hole n
597 MN _ _ -> unique_hole n
594 _ -> return n
598 _ -> return n
@@ -600,7 +604,7 @@ elab ist info pattern tm
600 elab' (PLet n ty val sc)
604 elab' (PLet n ty val sc)
601 = do attack;
605 = do attack;
602 tyn <- unique_hole (MN 0 "letty")
606 tyn <- unique_hole (MN 0 "letty")
603− claim tyn (RSet 0)
607+ claim tyn RSet
604 valn <- unique_hole (MN 0 "letval")
608 valn <- unique_hole (MN 0 "letval")
605 claim valn (Var tyn)
609 claim valn (Var tyn)
606 letbind n (Var tyn) (Var valn)
610 letbind n (Var tyn) (Var valn)
@@ -682,7 +686,7 @@ resolveTC depth ist
682 = do t <- goal
686 = do t <- goal
683 tm <- get_term
687 tm <- get_term
684 try (trivial ist)
688 try (trivial ist)
685− (blunderbuss t (map fst (toAlist (tt_ctxt ist))))
689+ (blunderbuss t (map fst (ctxtAlist (tt_ctxt ist))))
687 blunderbuss t [] = fail $ "Can't resolve type class " ++ show t
691 blunderbuss t [] = fail $ "Can't resolve type class " ++ show t
688 blunderbuss t (n:ns) | tcname n = try (resolve n depth)
692 blunderbuss t (n:ns) | tcname n = try (resolve n depth)
@@ -753,7 +757,7 @@ runTac autoSolve ist tac = runT (fmap (addImpl ist) tac) where
753 = do attack; -- (h:_) <- get_holes
757 = do attack; -- (h:_) <- get_holes
754 tyn <- unique_hole (MN 0 "rty")
758 tyn <- unique_hole (MN 0 "rty")
755 -- start_unify h
759 -- start_unify h
756− claim tyn (RSet 0)
760+ claim tyn RSet
757 valn <- unique_hole (MN 0 "rval")
761 valn <- unique_hole (MN 0 "rval")
758 claim valn (Var tyn)
762 claim valn (Var tyn)
759 letn <- unique_hole (MN 0 "rewrite_rule")
763 letn <- unique_hole (MN 0 "rewrite_rule")
@@ -765,7 +769,7 @@ runTac autoSolve ist tac = runT (fmap (addImpl ist) tac) where
765 runT (LetTac n tm)
769 runT (LetTac n tm)
766 = do attack
770 = do attack
767 tyn <- unique_hole (MN 0 "letty")
771 tyn <- unique_hole (MN 0 "letty")
768− claim tyn (RSet 0)
772+ claim tyn RSet
769 valn <- unique_hole (MN 0 "letval")
773 valn <- unique_hole (MN 0 "letval")
770 claim valn (Var tyn)
774 claim valn (Var tyn)
771 letn <- unique_hole n
775 letn <- unique_hole n