@@ -501,8 +501,8 @@ checkPiGoal n
501501 solve
502502 focus f
503503
504−simple_app :: Elab' aux () -> Elab' aux () -> Elab' aux ()
505−simple_app fun arg =
504+simple_app :: Elab' aux () -> Elab' aux () -> String -> Elab' aux ()
505+simple_app fun arg appstr =
506506 do a <- unique_hole (MN 0 "argTy")
507507 b <- unique_hole (MN 0 "retTy")
508508 f <- unique_hole (MN 0 "f")
@@ -514,24 +514,21 @@ simple_app fun arg =
514514 start_unify s
515515 claim s (Var a)
516516 prep_fill f [s]
517− -- try elaborating in both orders, since we might learn something useful
518− -- either way
519−-- try (do focus s; arg
520−-- focus f; fun)
521−-- (do focus f; fun
522−-- focus s; arg)
523517 focus f; fun
524518 focus s; arg
525519 tm <- get_term
526520 ps <- get_probs
527521 complete_fill
528522 hs <- get_holes
529− -- We don't need a and b in the hole queue any more since they were just for
530− -- checking f, so discard them if they are still there. If they haven't been solved,
531− -- regret will fail
532− when (a `elem` hs) $ do focus a; regret
533− when (b `elem` hs) $ do focus b; regret
523+ env <- get_env
524+ -- We don't need a and b in the hole queue any more since they were
525+ -- just for checking f, so discard them if they are still there.
526+ -- If they haven't been solved, regret will fail
527+ when (a `elem` hs) $ do focus a; regretWith (CantInferType appstr)
528+ when (b `elem` hs) $ do focus b; regretWith (CantInferType appstr)
534529 end_unify
530+ where regretWith err = try regret
531+ (lift $ tfail err)
535532
536533-- Abstract over an argument of unknown type, giving a name for the hole
537534-- which we'll fill with the argument type too.