@@ -95,9 +95,11 @@ errAt thing n elab = do s <- get
9595 case runStateT elab s of
9696 OK (a, s') -> do put s'
9797 return $! a
98− Error (At f e) ->
99− lift $ Error (At f (Elaborating thing n e))
100− Error e -> lift $ Error (Elaborating thing n e)
98+ Error e -> lift $ Error (rewriteErr e)
99+ where
100+ rewriteErr (At f e) = At f (rewriteErr e)
101+ rewriteErr (ProofSearchFail e) = ProofSearchFail (rewriteErr e)
102+ rewriteErr e = Elaborating thing n e
101103
102104erun :: FC -> Elab' aux a -> Elab' aux a
103105erun f elab = do s <- get
@@ -780,9 +782,7 @@ handleError p t1 t2
780782 Error e1 -> if p e1 then
781783 do case runStateT t2 s of
782784 OK (v, s') -> do put s'; return $! v
783− Error e2 -> if score e1 >= score e2
784− then lift (tfail e1)
785− else lift (tfail e2)
785+ Error e2 -> lift (tfail e2)
786786 else lift (tfail e1)
787787
788788try' :: Elab' aux a -> Elab' aux a -> Bool -> Elab' aux a
@@ -798,9 +798,7 @@ try' t1 t2 proofSearch
798798 if recoverableErr e1 then
799799 do case runStateT t2 s of
800800 OK (v, s') -> do put s'; return $! v
801− Error e2 -> if score e1 >= score e2
802− then lift (tfail e1)
803− else lift (tfail e2)
801+ Error e2 -> lift (tfail e2)
804802 else lift (tfail e1)
805803 where recoverableErr err@(CantUnify r x y _ _ _)
806804 = -- traceWhen r (show err) $
@@ -827,9 +825,7 @@ tryCatch t1 t2
827825 case runStateT (t2 e1) s of
828826 OK (v, s') -> do put s'
829827 return $! v
830− Error e2 -> if score e1 >= score e2
831− then lift (tfail e1)
832− else lift (tfail e2)
828+ Error e2 -> lift (tfail e2)
833829
834830tryWhen :: Bool -> Elab' aux a -> Elab' aux a -> Elab' aux a
835831tryWhen True a b = try a b
@@ -839,7 +835,7 @@ tryWhen False a b = a
839835-- to False, then the whole tactic fails if there are any new problems
840836tryAll :: [(Elab' aux a, Name)] -> Elab' aux a
841837tryAll [(x, _)] = x
842−tryAll xs = tryAll' [] 999999 (cantResolve, 0) xs
838+tryAll xs = tryAll' [] 999999 xs
843839 where
844840 cantResolve :: Elab' aux a
845841 cantResolve = lift $ tfail $ CantResolveAlts (map snd xs)
@@ -849,13 +845,12 @@ tryAll xs = tryAll' [] 999999 (cantResolve, 0) xs
849845
850846 tryAll' :: [Elab' aux a] -> -- successes
851847 Int -> -- most problems
852− (Elab' aux a, Int) -> -- smallest failure
853848 [(Elab' aux a, Name)] -> -- still to try
854849 Elab' aux a
855− tryAll' [res] pmax _ [] = res
856− tryAll' (_:_) pmax _ [] = cantResolve
857− tryAll' [] pmax (f, _) [] = noneValid
858− tryAll' cs pmax f ((x, msg):xs)
850+ tryAll' [res] pmax [] = res
851+ tryAll' (_:_) pmax [] = cantResolve
852+ tryAll' [] pmax [] = noneValid
853+ tryAll' cs pmax ((x, msg):xs)
859854 = do s <- get
860855 ps <- get_probs
861856 case prunStateT pmax True ps x s of
@@ -863,16 +858,9 @@ tryAll xs = tryAll' [] 999999 (cantResolve, 0) xs
863858 do let cs' = if (newps < pmax)
864859 then [do put s'; return $! v]
865860 else (do put s'; return $! v) : cs
866− tryAll' cs' newps f xs
861+ tryAll' cs' newps xs
867862 Error err -> do put s
868−-- if (score err) < 100
869− tryAll' cs pmax (better err f) xs
870−-- else tryAll' [] pmax (better err f) xs -- give up
871−
872−
873− better err (f, i) = let s = score err in
874− if (s >= i) then (lift (tfail err), s)
875− else (f, i)
863+ tryAll' cs pmax xs
876864
877865-- Run an elaborator, and fail if any problems are introduced
878866prunStateT