@@ -353,6 +353,9 @@ claimFn n bn t = processTactic' (ClaimFn n bn t)
353unifyGoal :: Raw -> Elab' aux ()
353unifyGoal :: Raw -> Elab' aux ()
354unifyGoal t = processTactic' (UnifyGoal t)
354unifyGoal t = processTactic' (UnifyGoal t)
356+unifyTerms :: Raw -> Raw -> Elab' aux ()
357+unifyTerms t1 t2 = processTactic' (UnifyTerms t1 t2)
356exact :: Raw -> Elab' aux ()
359exact :: Raw -> Elab' aux ()
357exact t = processTactic' (Exact t)
360exact t = processTactic' (Exact t)
@@ -724,7 +727,12 @@ checkPiGoal n
726simple_app :: Bool -> Elab' aux () -> Elab' aux () -> String -> Elab' aux ()
729simple_app :: Bool -> Elab' aux () -> Elab' aux () -> String -> Elab' aux ()
727−simple_app infer fun arg str =
730+simple_app infer fun arg str =
731+ try (dep_app fun arg str)
732+ (infer_app infer fun arg str)
734+infer_app :: Bool -> Elab' aux () -> Elab' aux () -> String -> Elab' aux ()
735+infer_app infer fun arg str =
728 do a <- getNameFrom (sMN 0 "__argTy")
736 do a <- getNameFrom (sMN 0 "__argTy")
729 b <- getNameFrom (sMN 0 "__retTy")
737 b <- getNameFrom (sMN 0 "__retTy")
730 f <- getNameFrom (sMN 0 "f")
738 f <- getNameFrom (sMN 0 "f")
@@ -755,8 +763,49 @@ simple_app infer fun arg str =
755 when (a `elem` hs) $ do movelast a
763 when (a `elem` hs) $ do movelast a
756 when (b `elem` hs) $ do movelast b
764 when (b `elem` hs) $ do movelast b
757 end_unify
765 end_unify
759− regretWith err = try regret (lift $ tfail err)
767+dep_app :: Elab' aux () -> Elab' aux () -> String -> Elab' aux ()
768+dep_app fun arg str =
769+ do a <- getNameFrom (sMN 0 "__argTy")
770+ b <- getNameFrom (sMN 0 "__retTy")
771+ fty <- getNameFrom (sMN 0 "__fnTy")
772+ f <- getNameFrom (sMN 0 "f")
773+ s <- getNameFrom (sMN 0 "s")
783+ focus f; attack; fun
790+ case normalise ctxt env fty of
791+ -- if f gives a function type, unify our argument type with
792+ -- f's expected argument type
793+ Bind _ (Pi _ argty _) _ -> unifyGoal (forget argty)
794+ -- Can't infer a type for 'f', so fail here (and drop back to
795+ -- simply typed application where we infer the type for f)
796+ _ -> fail "Can't make type"
802+ -- We don't need a and b in the hole queue any more since they were
803+ -- just for checking f, so move them to the end. If they never end up
804+ -- getting solved, we'll get an 'Incomplete term' error.
806+ when (a `elem` hs) $ do movelast a
807+ when (b `elem` hs) $ do movelast b
761-- Abstract over an argument of unknown type, giving a name for the hole
810-- Abstract over an argument of unknown type, giving a name for the hole
762-- which we'll fill with the argument type too.
811-- which we'll fill with the argument type too.