@@ -1502,7 +1502,21 @@ elab ist info emode opts fn tm
1502 fullApp (PApp _ (PApp fc f args) xs) = fullApp (PApp fc f (args ++ xs))
1502 fullApp (PApp _ (PApp fc f args) xs) = fullApp (PApp fc f (args ++ xs))
1503 fullApp x = x
1503 fullApp x = x
1505+ -- See if the name is listed as an implicit. If it is, return it, and
1506+ -- drop it from the rest of the list
1507+ findImplicit :: Name -> [PArg] -> (Maybe PArg, [PArg])
1508+ findImplicit n [] = (Nothing, [])
1509+ findImplicit n (i@(PImp _ _ _ n' _) : args)
1510+ | n == n' = (Just i, args)
1511+ findImplicit n (i@(PTacImplicit _ _ n' _ _) : args)
1512+ | n == n' = (Just i, args)
1513+ findImplicit n (x : xs) = let (arg, rest) = findImplicit n xs in
1505 insertScopedImps fc ty@(Bind n (Pi _ im@(Just i) _ _) sc) xs
1516 insertScopedImps fc ty@(Bind n (Pi _ im@(Just i) _ _) sc) xs
1517+ | (Just arg, xs') <- findImplicit n xs,
1518+ not (toplevel_imp i)
1519+ = arg : insertScopedImps fc sc xs'
1506 | tcimplementation i && not (toplevel_imp i)
1520 | tcimplementation i && not (toplevel_imp i)
1507 = pimp n (PResolveTC fc) True : insertScopedImps fc sc xs
1521 = pimp n (PResolveTC fc) True : insertScopedImps fc sc xs
1508 | not (toplevel_imp i)
1522 | not (toplevel_imp i)