@@ -61,8 +61,10 @@ elabTransform info fc safe lhs_in@(PApp _ (PRef _ tf) _) rhs_in
61 let lhs_ty = getInferType lhs'
61 let lhs_ty = getInferType lhs'
62 let newargs = pvars i lhs_tm
62 let newargs = pvars i lhs_tm
64− (clhs_tm, clhs_ty) <- recheckC fc [] lhs_tm
64+ (clhs_tm_in, clhs_ty) <- recheckC fc [] lhs_tm
65+ let clhs_tm = renamepats pnames clhs_tm_in
65 logLvl 3 ("Transform LHS " ++ show clhs_tm)
66 logLvl 3 ("Transform LHS " ++ show clhs_tm)
66 let rhs = addImplBound i (map fst newargs) rhs_in
68 let rhs = addImplBound i (map fst newargs) rhs_in
67 ((rhs', defer), _) <-
69 ((rhs', defer), _) <-
68 tclift $ elaborate ctxt (sMN 0 "transRHS") clhs_ty []
70 tclift $ elaborate ctxt (sMN 0 "transRHS") clhs_ty []
@@ -72,8 +74,10 @@ elabTransform info fc safe lhs_in@(PApp _ (PRef _ tf) _) rhs_in
72 erun fc $ psolve lhs_tm
74 erun fc $ psolve lhs_tm
73 tt <- get_term
75 tt <- get_term
74 return (runState (collectDeferred Nothing tt) []))
76 return (runState (collectDeferred Nothing tt) []))
75− (crhs_tm, crhs_ty) <- recheckC fc [] rhs'
77+ (crhs_tm_in, crhs_ty) <- recheckC fc [] rhs'
78+ let crhs_tm = renamepats pnames crhs_tm_in
76 logLvl 3 ("Transform RHS " ++ show crhs_tm)
79 logLvl 3 ("Transform RHS " ++ show crhs_tm)
77 -- Types must always convert
81 -- Types must always convert
78 case converts ctxt [] clhs_ty crhs_ty of
82 case converts ctxt [] clhs_ty crhs_ty of
79 OK _ -> return ()
83 OK _ -> return ()
@@ -94,6 +98,14 @@ elabTransform info fc safe lhs_in@(PApp _ (PRef _ tf) _) rhs_in
94 depat (Bind n (PVar t) sc) = depat (instantiate (P Bound n t) sc)
98 depat (Bind n (PVar t) sc) = depat (instantiate (P Bound n t) sc)
95 depat x = x
99 depat x = x
101+ renamepats (n' : ns) (Bind n (PVar t) sc)
102+ = Bind n' (PVar t) (renamepats ns sc) -- all Vs
103+ renamepats _ sc = sc
105+ -- names for transformation variables. Need to ensure these don't clash
106+ -- with any other names when applying rules, so rename here.
107+ pnames = map (\i -> sMN i ("tvar" ++ show i)) [0..]
97elabTransform info fc safe lhs_in rhs_in
109elabTransform info fc safe lhs_in rhs_in
98 = ierror (At fc (Msg "Invalid transformation rule (must be function application)"))
110 = ierror (At fc (Msg "Invalid transformation rule (must be function application)"))