@@ -147,19 +147,20 @@ renameInModule imports (Module mn decls) =
147 Module mn <$> mapM updateDecl decls >>= everywhereM (mkM updateType `extM` updateValue `extM` updateBinder)
147 Module mn <$> mapM updateDecl decls >>= everywhereM (mkM updateType `extM` updateValue `extM` updateBinder)
149 updateDecl (TypeInstanceDeclaration cs (Qualified Nothing cn) ts ds) =
149 updateDecl (TypeInstanceDeclaration cs (Qualified Nothing cn) ts ds) =
150− TypeInstanceDeclaration <$> updateConstraints cs <*> updateClassName cn <*> pure ts <*> pure ds
150+ TypeInstanceDeclaration <$> updateConstraints cs <*> updateClassName cn <*> pure ts <*> updateVars ds
151 updateDecl (ValueDeclaration name bs grd val) =
151 updateDecl (ValueDeclaration name bs grd val) =
152 ValueDeclaration name <$> updateVars bs <*> updateVars grd <*> updateVars val
152 ValueDeclaration name <$> updateVars bs <*> updateVars grd <*> updateVars val
154− updateVars :: (Data d) => d -> Either String d
155− updateVars = everywhereWithContextM' [] (mkS bindFunctionArgs `extS` bindBinders)
157− bindFunctionArgs bound (Abs (Left arg) val) = return (arg : bound, Abs (Left arg) val)
158− bindFunctionArgs bound (Var (Qualified Nothing ident)) | ident `notElem` bound = (,) bound <$> (Var <$> updateValueName ident)
159− bindFunctionArgs bound other = return (bound, other)
160− bindBinders :: [Ident] -> ([Binder], Maybe Guard, Value) -> Either String ([Ident], ([Binder], Maybe Guard, Value))
161− bindBinders bound (bs, grd, val) = return (binderNames bs ++ bound, (bs, grd, val))
162 updateDecl d = return d
153 updateDecl d = return d
155+ updateVars :: (Data d) => d -> Either String d
156+ updateVars = everywhereWithContextM' [] (mkS bindFunctionArgs `extS` bindBinders)
158+ bindFunctionArgs bound (Abs (Left arg) val) = return (arg : bound, Abs (Left arg) val)
159+ bindFunctionArgs bound (Var (Qualified Nothing ident)) | ident `notElem` bound = (,) bound <$> (Var <$> updateValueName ident)
160+ bindFunctionArgs bound other = return (bound, other)
161+ bindBinders :: [Ident] -> CaseAlternative -> Either String ([Ident], CaseAlternative)
162+ bindBinders bound c@(CaseAlternative bs _ _) = return (binderNames bs ++ bound, c)
163 updateValue (Constructor (Qualified Nothing nm)) =
164 updateValue (Constructor (Qualified Nothing nm)) =
164 Constructor <$> updateDataConstructorName nm
165 Constructor <$> updateDataConstructorName nm
165 updateValue v = return v
166 updateValue v = return v