@@ -435,13 +435,20 @@ elab ist info emode opts fn tm
435 bindable (UN xs) = True
435 bindable (UN xs) = True
436 bindable n = implicitable n
436 bindable n = implicitable n
437 elab' ina _ f@(PInferRef fc n) = elab' ina (Just fc) (PApp fc f [])
437 elab' ina _ f@(PInferRef fc n) = elab' ina (Just fc) (PApp fc f [])
438− elab' ina _ tm@(PRef fc n)
438+ elab' ina fc' tm@(PRef fc n)
439 | pattern && not reflection && not (e_qq ina) && not (e_intype ina)
439 | pattern && not reflection && not (e_qq ina) && not (e_intype ina)
440 && isTConName n (tt_ctxt ist)
440 && isTConName n (tt_ctxt ist)
441 = lift $ tfail $ Msg ("No explicit types on left hand side: " ++ show tm)
441 = lift $ tfail $ Msg ("No explicit types on left hand side: " ++ show tm)
442 | pattern && not reflection && e_nomatching ina
442 | pattern && not reflection && e_nomatching ina
443 = lift $ tfail $ Msg ("Attempting concrete match on polymorphic argument: " ++ show tm)
443 = lift $ tfail $ Msg ("Attempting concrete match on polymorphic argument: " ++ show tm)
445+ do fty <- get_type (Var n) -- check for implicits
448+ let a' = insertScopedImps fc (normalise ctxt env fty) []
444− | otherwise = erun fc $ do apply (Var n) []; solve
450+ then erun fc $ do apply (Var n) []; solve
451+ else elab' ina fc' (PApp fc tm [])
445 elab' ina _ (PLam fc n Placeholder sc)
452 elab' ina _ (PLam fc n Placeholder sc)
446 = do -- if n is a type constructor name, this makes no sense...
453 = do -- if n is a type constructor name, this makes no sense...
447 ctxt <- get_context
454 ctxt <- get_context
@@ -565,7 +572,7 @@ elab ist info emode opts fn tm
565 ans <- claimArgTys env xs
572 ans <- claimArgTys env xs
566 return ((aval, (True, (Var an))) : ans)
573 return ((aval, (True, (Var an))) : ans)
567 fnTy [] ret = forget ret
574 fnTy [] ret = forget ret
568− fnTy ((x, (_, xt)) : xs) ret = RBind x (Pi False xt RType) (fnTy xs ret)
575+ fnTy ((x, (_, xt)) : xs) ret = RBind x (Pi Nothing xt RType) (fnTy xs ret)
570 localVar env (PRef _ x)
577 localVar env (PRef _ x)
571 = case lookup x env of
578 = case lookup x env of
@@ -603,17 +610,17 @@ elab ist info emode opts fn tm
603 ty <- goal
610 ty <- goal
604 fty <- get_type (Var f)
611 fty <- get_type (Var f)
605 ctxt <- get_context
612 ctxt <- get_context
606− let args = insertScopedImps (normalise ctxt env fty) args_in
613+ let args = insertScopedImps fc (normalise ctxt env fty) args_in
607 let unmatchableArgs = if pattern
614 let unmatchableArgs = if pattern
608 then getUnmatchable (tt_ctxt ist) f
615 then getUnmatchable (tt_ctxt ist) f
610 -- Dot it if we're in a pattern and it isn't a constructor
617 -- Dot it if we're in a pattern and it isn't a constructor
611-- when (pattern && not (isDConName f ctxt) && f /= fn) $ dotterm
618-- when (pattern && not (isDConName f ctxt) && f /= fn) $ dotterm
613 when (pattern && not reflection && not (e_qq ina) && not (e_intype ina)
620 when (pattern && not reflection && not (e_qq ina) && not (e_intype ina)
614 && isTConName f (tt_ctxt ist)) $
621 && isTConName f (tt_ctxt ist)) $
615 lift $ tfail $ Msg ("No explicit types on left hand side: " ++ show tm)
622 lift $ tfail $ Msg ("No explicit types on left hand side: " ++ show tm)
616− if (f `elem` map fst env && length args == 1)
623+ if (f `elem` map fst env && length args == 1 && length args_in == 1)
617 then -- simple app, as below
624 then -- simple app, as below
618 do simple_app (elabE ina (Just fc) (PRef fc f))
625 do simple_app (elabE ina (Just fc) (PRef fc f))
619 (elabE (ina { e_inarg = True }) (Just fc) (getTm (head args)))
626 (elabE (ina { e_inarg = True }) (Just fc) (getTm (head args)))
@@ -1052,11 +1059,14 @@ elab ist info emode opts fn tm
1052 notImplicitable (PCase _ _ _) = True
1059 notImplicitable (PCase _ _ _) = True
1053 notImplicitable _ = False
1060 notImplicitable _ = False
1055− insertScopedImps (Bind n (Pi True _ _) sc) xs
1062+ insertScopedImps fc (Bind n (Pi im@(Just i) _ _) sc) xs
1064+ = pimp n (PResolveTC fc) True : insertScopedImps fc sc xs
1056− = pimp n Placeholder True : insertScopedImps sc xs
1066+ = pimp n Placeholder True : insertScopedImps fc sc xs
1057− insertScopedImps (Bind n (Pi _ _ _) sc) (x : xs)
1067+ insertScopedImps fc (Bind n (Pi _ _ _) sc) (x : xs)
1058− = x : insertScopedImps sc xs
1068+ = x : insertScopedImps fc sc xs
1059− insertScopedImps _ xs = xs
1069+ insertScopedImps _ _ xs = xs
1061 insertImpLam t =
1071 insertImpLam t =
1062 do ty <- goal
1072 do ty <- goal
@@ -1064,10 +1074,10 @@ elab ist info emode opts fn tm
1064 let ty' = normalise (tt_ctxt ist) env ty
1074 let ty' = normalise (tt_ctxt ist) env ty
1065 addLam ty' t
1075 addLam ty' t
1077+ -- just one level at a time
1067− addLam (Bind n (Pi True _ _) sc) t
1078+ addLam (Bind n (Pi (Just _) _ _) sc) t
1068 = do impn <- unique_hole (sMN 0 "imp")
1079 = do impn <- unique_hole (sMN 0 "imp")
1070− return (PLam emptyFC impn Placeholder t')
1080+ return (PLam emptyFC impn Placeholder t)
1071 addLam _ t = return t
1081 addLam _ t = return t
1073 insertCoerce ina t@(PCase _ _ _) = return t
1083 insertCoerce ina t@(PCase _ _ _) = return t
@@ -1537,9 +1547,9 @@ runTac autoSolve ist perhapsFC fn tac
1537 where tacticTy = Var (reflm "Tactic")
1547 where tacticTy = Var (reflm "Tactic")
1538 listTy = Var (sNS (sUN "List") ["List", "Prelude"])
1548 listTy = Var (sNS (sUN "List") ["List", "Prelude"])
1539 scriptTy = (RBind (sMN 0 "__pi_arg")
1549 scriptTy = (RBind (sMN 0 "__pi_arg")
1540− (Pi False (RApp listTy envTupleType) RType)
1550+ (Pi Nothing (RApp listTy envTupleType) RType)
1541 (RBind (sMN 1 "__pi_arg")
1551 (RBind (sMN 1 "__pi_arg")
1542− (Pi False (Var $ reflm "TT") RType) tacticTy))
1552+ (Pi Nothing (Var $ reflm "TT") RType) tacticTy))
1543 runT (ByReflection tm) -- run the reflection function 'tm' on the
1553 runT (ByReflection tm) -- run the reflection function 'tm' on the
1544 -- goal, then apply the resulting reflected Tactic
1554 -- goal, then apply the resulting reflected Tactic
1545 = do tgoal <- goal
1555 = do tgoal <- goal
@@ -1812,7 +1822,7 @@ reifyTTBinderApp :: (Term -> ElabD a) -> Name -> [Term] -> ElabD (Binder a)
1812reifyTTBinderApp reif f [t]
1822reifyTTBinderApp reif f [t]
1813 | f == reflm "Lam" = liftM Lam (reif t)
1823 | f == reflm "Lam" = liftM Lam (reif t)
1814reifyTTBinderApp reif f [t, k]
1824reifyTTBinderApp reif f [t, k]
1815− | f == reflm "Pi" = liftM2 (Pi False) (reif t) (reif k)
1825+ | f == reflm "Pi" = liftM2 (Pi Nothing) (reif t) (reif k)
1816reifyTTBinderApp reif f [x, y]
1826reifyTTBinderApp reif f [x, y]
1817 | f == reflm "Let" = liftM2 Let (reif x) (reif y)
1827 | f == reflm "Let" = liftM2 Let (reif x) (reif y)
1818reifyTTBinderApp reif f [x, y]
1828reifyTTBinderApp reif f [x, y]