@@ -147,19 +147,20 @@ renameInModule imports (Module mn decls) =
147147 Module mn <$> mapM updateDecl decls >>= everywhereM (mkM updateType `extM` updateValue `extM` updateBinder)
148148 where
149149 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
151151 updateDecl (ValueDeclaration name bs grd val) =
152152 ValueDeclaration name <$> updateVars bs <*> updateVars grd <*> updateVars val
153− where
154− updateVars :: (Data d) => d -> Either String d
155− updateVars = everywhereWithContextM' [] (mkS bindFunctionArgs `extS` bindBinders)
156− where
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))
162153 updateDecl d = return d
154+
155+ updateVars :: (Data d) => d -> Either String d
156+ updateVars = everywhereWithContextM' [] (mkS bindFunctionArgs `extS` bindBinders)
157+ where
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+
163164 updateValue (Constructor (Qualified Nothing nm)) =
164165 Constructor <$> updateDataConstructorName nm
165166 updateValue v = return v