@@ -48,7 +48,7 @@ data Tactic = Attack
4848 | Intro Name
4949 | Forall Name Raw
5050 | PatVar Name
51− | PatBind Name Raw
51+ | PatBind Name
5252 | Focus Name
5353 | MoveLast Name
5454 | ProofState
@@ -239,12 +239,14 @@ patvar n ctxt env (Bind x (Hole t) sc) =
239239 do action (\ps -> ps { holes = holes ps \\ [x] })
240240 return $ Bind n (PVar t) (instantiate (P Bound n t) (pToV x sc))
241241
242−patbind :: Name -> Raw -> RunTactic
243−patbind n ty ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
244− do (tyv, tyt) <- lift $ check ctxt env ty
245− lift $ isSet ctxt env tyt
246− return $ Bind n (PVar tyv) (Bind x (Hole t) (P Bound x t))
247−patbind n ty ctxt env _ = fail "Can't pattern bind here"
242+patbind :: Name -> RunTactic
243+patbind n ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
244+ do let t' = normalise ctxt env t
245+ case t' of
246+ Bind y (PVTy s) t -> let t' = instantiate (P Bound n s) (pToV y t) in
247+ return $ Bind n (PVar s) (Bind x (Hole t') (P Bound x t'))
248+ _ -> fail "Nothing to pattern bind"
249+patbind n ctxt env _ = fail "Can't pattern bind here"
248250
249251compute :: RunTactic
250252compute ctxt env (Bind x (Hole ty) sc) =
@@ -345,7 +347,7 @@ process t h = tactic (Just h) (mktac t)
345347 mktac (Intro n) = intro n
346348 mktac (Forall n t) = forall n t
347349 mktac (PatVar n) = patvar n
348− mktac (PatBind n t) = patbind n t
350+ mktac (PatBind n) = patbind n
349351 mktac (CheckIn r) = check_in r
350352 mktac (EvalIn r) = eval_in r
351353 mktac (Focus n) = focus n