@@ -27,6 +27,10 @@ data ElabInfo = EInfo { params :: [(Name, PTerm)],
2727
2828toplevel = EInfo [] emptyContext id
2929
30+checkDef ns = do ctxt <- getContext
31+ mapM (\(n, t) -> do (t', _) <- tclift $ recheck ctxt [] t
32+ return (n, t')) ns
33+
3034elabType :: ElabInfo -> FC -> Name -> PTerm -> Idris ()
3135elabType info fc n_in ty_in = let ty = piBind (params info) ty_in
3236 n = liftname info n_in in
@@ -38,7 +42,8 @@ elabType info fc n_in ty_in = let ty = piBind (params info) ty_in
3842 (cty, _) <- tclift $ recheck ctxt [] ty'
3943 logLvl 2 $ "---> " ++ show cty
4044 let nty = normalise ctxt [] cty
41− addDeferred ((n, nty):defer)
45+ ds <- checkDef ((n, nty):defer)
46+ addDeferred ds
4247
4348elabData :: ElabInfo -> FC -> PData -> Idris ()
4449elabData info fc (PDatadecl n t dcons)
@@ -47,7 +52,8 @@ elabData info fc (PDatadecl n t dcons)
4752 ctxt <- getContext
4853 ((t', defer), log) <- tclift $ elaborate ctxt n (Set 0)
4954 (erun fc (build info False t))
50− addDeferred defer
55+ def' <- checkDef defer
56+ addDeferred def'
5157 (cty, _) <- tclift $ recheck ctxt [] t'
5258 logLvl 2 $ "---> " ++ show cty
5359 updateContext (addTyDecl n cty) -- temporary, to check cons
@@ -63,7 +69,8 @@ elabCon info (n, t, fc)
6369 ((t', defer), log) <- tclift $ elaborate ctxt n (Set 0)
6470 (erun fc (build info False t))
6571 logLvl 2 $ "Rechecking " ++ show t'
66− addDeferred defer
72+ def' <- checkDef defer
73+ addDeferred def'
6774 (cty, _) <- tclift $ recheck ctxt [] t'
6875 logLvl 2 $ "---> " ++ show n ++ " : " ++ show cty
6976 return (n, cty)
@@ -128,7 +135,8 @@ elabClause info fc (PClause fname lhs withs rhs whereblock)
128135 return $ runState (collectDeferred tt) [])
129136 logLvl 2 $ "---> " ++ show rhs'
130137 when (not (null defer)) $ iLOG $ "DEFERRED " ++ show defer
131− addDeferred defer
138+ def' <- checkDef defer
139+ addDeferred def'
132140 ctxt <- getContext
133141 (crhs, crhsty) <- tclift $ recheck ctxt [] rhs'
134142 return (clhs, crhs)
@@ -170,7 +178,8 @@ elabClause info fc (PWith fname lhs withs wval withblock)
170178 psolve lhs_tm
171179 tt <- get_term
172180 return (tt, d))
173− addDeferred defer
181+ def' <- checkDef defer
182+ addDeferred def'
174183 (cwval, cwvalty) <- tclift $ recheck ctxt [] (getInferTerm wval')
175184 logLvl 3 ("With type " ++ show cwvalty ++ "\nRet type " ++ show ret_ty)
176185 windex <- getName
@@ -179,7 +188,8 @@ elabClause info fc (PWith fname lhs withs wval withblock)
179188 let wtype = bindTyArgs Pi (bargs ++ [(MN 0 "warg", getRetTy cwvalty)]) ret_ty
180189 logLvl 3 ("New function type " ++ show wtype)
181190 let wname = MN windex (show fname)
182− addDeferred [(wname, wtype)]
191+ def' <- checkDef [(wname, wtype)]
192+ addDeferred def'
183193
184194 -- in the subdecls, lhs becomes:
185195 -- fname pats | wpat [rest]
@@ -200,7 +210,8 @@ elabClause info fc (PWith fname lhs withs wval withblock)
200210 psolve lhs_tm
201211 tt <- get_term
202212 return (tt, d))
203− addDeferred defer
213+ def' <- checkDef defer
214+ addDeferred def'
204215 (crhs, crhsty) <- tclift $ recheck ctxt [] rhs'
205216 return (clhs, crhs)
206217 where
@@ -346,7 +357,7 @@ elab info pattern tm = do elab' tm
346357 = elab' (PApp fc (PRef fc n) [])
347358 | otherwise = erun fc $ do apply (Var n) []; solve
348359 elab' (PLam n Placeholder sc)
349− = do attack; intro n; elab' sc; solve
360+ = do attack; intro (Just n); elab' sc; solve
350361 elab' (PPi _ n Placeholder sc)
351362 = do attack; arg n (MN 0 "ty"); elab' sc; solve
352363 elab' (PPi _ n ty sc)
@@ -424,7 +435,12 @@ collectDeferred t = return t
424435
425436runTac :: Bool -> PTactic -> Elab ()
426437runTac autoSolve = runT where
427− runT (Intro xs) = mapM_ (\x -> do attack; intro x) xs
438+ runT (Intro []) = do g <- goal
439+ attack; intro (bname g)
440+ where
441+ bname (Bind n _ _) = Just n
442+ bname _ = Nothing
443+ runT (Intro xs) = mapM_ (\x -> do attack; intro (Just x)) xs
428444 runT (Exact tm) = do elab toplevel False tm
429445 when autoSolve solveAll
430446 runT (Refine fn imps) = do ns <- apply (Var fn) imps
@@ -442,6 +458,16 @@ runTac autoSolve = runT where
442458 elab toplevel False tm
443459 rewrite (Var letn)
444460 when autoSolve solveAll
461+ runT Compute = compute
462+ runT Trivial = try (do elab toplevel False (PRefl (FC "prf" 0))
463+ when autoSolve solveAll)
464+ (do env <- get_env
465+ tryAll (map fst env))
466+ where
467+ tryAll [] = fail "No trivial solution"
468+ tryAll (x:xs) = try (do elab toplevel False (PRef (FC "prf" 0) x)
469+ when autoSolve solveAll)
470+ (tryAll xs)
445471 runT (Focus n) = focus n
446472 runT Solve = solve
447473 runT x = fail $ "Not implemented " ++ show x