@@ -293,8 +293,9 @@ elab ist info pattern tcgen fn tm
293 tryWhen True
293 tryWhen True
294 (do ns <- apply (Var f) (map isph args)
294 (do ns <- apply (Var f) (map isph args)
295 let (ns', eargs)
295 let (ns', eargs)
296− = unzip $
296+ = unzip $
297+ sortBy (\(_,x) (_,y) ->
297− sortBy (\(_,x) (_,y) -> compare (priority x) (priority y))
298+ compare (priority x) (priority y))
298 (zip ns args)
299 (zip ns args)
300 (elabArgs (ina || not isinf, guarded)
301 (elabArgs (ina || not isinf, guarded)
@@ -317,6 +318,10 @@ elab ist info pattern tcgen fn tm
317 where tcArg (n, PConstraint _ _ Placeholder _) = True
318 where tcArg (n, PConstraint _ _ Placeholder _) = True
318 tcArg _ = False
319 tcArg _ = False
321+ tacTm (PTactics _) = True
322+ tacTm (PProof _) = True
320 elab' ina@(_, a) (PApp fc f [arg])
325 elab' ina@(_, a) (PApp fc f [arg])
321 = erun fc $
326 = erun fc $
322 do ptm <- get_term
327 do ptm <- get_term
@@ -630,10 +635,44 @@ runTac autoSolve ist tac = do env <- get_env
630 runT Trivial = do trivial ist; when autoSolve solveAll
635 runT Trivial = do trivial ist; when autoSolve solveAll
631 runT (Focus n) = focus n
636 runT (Focus n) = focus n
632 runT Solve = solve
637 runT Solve = solve
633− runT (Try l r) = do try (runT l) (runT r)
638+ runT (Try l r) = do try' (runT l) (runT r) True
634 runT (TSeq l r) = do runT l; runT r
639 runT (TSeq l r) = do runT l; runT r
640+ runT (ReflectTac tm) = do attack -- let x : Tactic = tm in ...
641+ valn <- unique_hole (MN 0 "tacval")
642+ claim valn (Var tacticTy)
643+ tacn <- unique_hole (MN 0 "tacn")
644+ letbind tacn (Var tacticTy) (Var valn)
646+ elab ist toplevel False False (MN 0 "tac") tm
647+ (tm', ty') <- get_type_val (Var tacn)
651+ let tactic = normalise ctxt env tm'
654+-- trace (show p ++ "\n\n") $
656+ where tacticTy = tacm "Tactic"
635 runT x = fail $ "Not implemented " ++ show x
657 runT x = fail $ "Not implemented " ++ show x
659+ runReflected t = do t' <- reify t
660+ runTac autoSolve ist t'
661+ tacm n = NS (UN n) ["Reflection", "Language"]
663+ reify :: Term -> ElabD PTactic
664+ reify (P _ n _) | n == tacm "Trivial" = return Trivial
665+ reify (P _ n _) | n == tacm "Solve" = return Solve
667+ | (P _ f _, args) <- unApply f = reifyAp f args
668+ reify t = fail "Unknown tactic"
670+ reifyAp t [l, r] | t == tacm "Try" = liftM2 Try (reify l) (reify r)
671+ reifyAp t [Constant (Str x)]
672+ | t == tacm "Refine" = return $ Refine (UN x) []
673+ reifyAp t [l, r] | t == tacm "Seq" = liftM2 TSeq (reify l) (reify r)
674+ reifyAp f args = fail "Unknown tactic" -- shouldn't happen
637solveAll = try (do solve; solveAll) (return ())
676solveAll = try (do solve; solveAll) (return ())
639-- If the function application is specialisable, make a new
678-- If the function application is specialisable, make a new