@@ -253,7 +253,7 @@ qed = do processTactic' QED
253undo :: Elab' aux ()
253undo :: Elab' aux ()
254undo = processTactic' Undo
254undo = processTactic' Undo
256−prepare_apply :: Raw -> [(Bool, Int)] -> Elab' aux [Name]
256+prepare_apply :: Raw -> [Bool] -> Elab' aux [Name]
257prepare_apply fn imps =
257prepare_apply fn imps =
258 do ty <- get_type fn
258 do ty <- get_type fn
259 ctxt <- get_context
259 ctxt <- get_context
@@ -262,7 +262,7 @@ prepare_apply fn imps =
262 claims <- mkClaims (normalise ctxt env ty) imps []
262 claims <- mkClaims (normalise ctxt env ty) imps []
263 ES (p, a) s prev <- get
263 ES (p, a) s prev <- get
264 -- reverse the claims we made so that args go left to right
264 -- reverse the claims we made so that args go left to right
265− let n = length (filter not (map fst imps))
265+ let n = length (filter not imps)
266 let (h : hs) = holes p
266 let (h : hs) = holes p
267 put (ES (p { holes = h : (reverse (take n hs) ++ drop n hs) }, a) s prev)
267 put (ES (p { holes = h : (reverse (take n hs) ++ drop n hs) }, a) s prev)
268-- case claims of
268-- case claims of
@@ -275,7 +275,7 @@ prepare_apply fn imps =
275-- when (null claims) (start_unify n)
275-- when (null claims) (start_unify n)
276 let sc' = instantiate (P Bound n t) sc
276 let sc' = instantiate (P Bound n t) sc
277 claim n (forget t)
277 claim n (forget t)
278− when (fst i) (movelast n)
278+ when i (movelast n)
279 mkClaims sc' is (n : claims)
279 mkClaims sc' is (n : claims)
280 mkClaims t [] claims = return (reverse claims)
280 mkClaims t [] claims = return (reverse claims)
281 mkClaims _ _ _ = fail $ "Wrong number of arguments for " ++ show fn
281 mkClaims _ _ _ = fail $ "Wrong number of arguments for " ++ show fn
@@ -289,20 +289,40 @@ prepare_apply fn imps =
290apply :: Raw -> [(Bool, Int)] -> Elab' aux [Name]
290apply :: Raw -> [(Bool, Int)] -> Elab' aux [Name]
291apply fn imps =
291apply fn imps =
292− do args <- prepare_apply fn imps
292+ do args <- prepare_apply fn (map fst imps)
293 fill (raw_apply fn (map Var args))
293 fill (raw_apply fn (map Var args))
294 -- *Don't* solve the arguments we're specifying by hand.
294 -- *Don't* solve the arguments we're specifying by hand.
295 -- (remove from unified list before calling end_unify)
295 -- (remove from unified list before calling end_unify)
296 -- HMMM: Actually, if we get it wrong, the typechecker will complain!
296 -- HMMM: Actually, if we get it wrong, the typechecker will complain!
297 -- so do nothing
297 -- so do nothing
298 ptm <- get_term
298 ptm <- get_term
299− let dontunify = [] -- map fst (filter (not.snd) (zip args imps))
299+ let dontunify = [] -- map fst (filter (not.snd) (zip args (map fst imps)))
300 ES (p, a) s prev <- get
300 ES (p, a) s prev <- get
301 let (n, hs) = unified p
301 let (n, hs) = unified p
302 let unify = (n, filter (\ (n, t) -> not (n `elem` dontunify)) hs)
302 let unify = (n, filter (\ (n, t) -> not (n `elem` dontunify)) hs)
303 put (ES (p { unified = unify }, a) s prev)
303 put (ES (p { unified = unify }, a) s prev)
304 end_unify
304 end_unify
305− return args
305+ return (map (updateUnify hs) args)
306+ where updateUnify hs n = case lookup n hs of
310+apply2 :: Raw -> [Maybe (Elab' aux ())] -> Elab' aux ()
312+ do args <- prepare_apply fn (map isJust elabs)
313+ fill (raw_apply fn (map Var args))
315+ ES (p, a) s prev <- get
316+ let (n, hs) = unified p
319+ where elabArgs [] [] = return ()
320+ elabArgs (n:ns) (Just e:es) = do focus n; e
322+ elabArgs (n:ns) (_:es) = elabArgs ns es
324+ isJust (Just _) = False
307apply_elab :: Name -> [Maybe (Int, Elab' aux ())] -> Elab' aux ()
327apply_elab :: Name -> [Maybe (Int, Elab' aux ())] -> Elab' aux ()
308apply_elab n args =
328apply_elab n args =