@@ -23,7 +23,7 @@ import Data.Generics (extM, mkM, everywhereM)
23import Data.Generics.Extras (mkS, extS, everywhereWithContextM')
23import Data.Generics.Extras (mkS, extS, everywhereWithContextM')
25import Control.Applicative (Applicative(..), (<$>), (<*>))
25import Control.Applicative (Applicative(..), (<$>), (<*>))
26−import Control.Monad (forM_, unless, foldM, liftM)
26+import Control.Monad (forM_, unless, foldM)
28import qualified Data.Map as M
28import qualified Data.Map as M
29import qualified Data.Set as S
29import qualified Data.Set as S
@@ -140,19 +140,21 @@ renameInModule imports (Module mn decls) =
140 bindBinders :: [Ident] -> ([Binder], Maybe Guard, Value) -> Either String ([Ident], ([Binder], Maybe Guard, Value))
140 bindBinders :: [Ident] -> ([Binder], Maybe Guard, Value) -> Either String ([Ident], ([Binder], Maybe Guard, Value))
141 bindBinders bound (bs, grd, val) = return (binderNames bs ++ bound, (bs, grd, val))
141 bindBinders bound (bs, grd, val) = return (binderNames bs ++ bound, (bs, grd, val))
142 updateDecl d = return d
142 updateDecl d = return d
143− updateValue (Constructor (Qualified Nothing nm)) = liftM Constructor $ updateDataConstructorName nm
143+ updateValue (Constructor (Qualified Nothing nm)) =
144+ Constructor <$> updateDataConstructorName nm
144 updateValue v = return v
145 updateValue v = return v
145− updateBinder (ConstructorBinder (Qualified Nothing nm) b) = liftM (`ConstructorBinder` b) $ updateDataConstructorName nm
146+ updateBinder (ConstructorBinder (Qualified Nothing nm) b) =
147+ ConstructorBinder <$> updateDataConstructorName nm <*> pure b
146 updateBinder v = return v
148 updateBinder v = return v
147− updateType (TypeConstructor (Qualified Nothing nm)) = liftM TypeConstructor $ updateTypeName nm
149+ updateType (TypeConstructor (Qualified Nothing nm)) =
150+ TypeConstructor <$> updateTypeName nm
148 updateType (SaturatedTypeSynonym (Qualified Nothing nm) tys) =
151 updateType (SaturatedTypeSynonym (Qualified Nothing nm) tys) =
149− SaturatedTypeSynonym <$> updateTypeName nm <*> mapM updateType tys
152+ SaturatedTypeSynonym <$> updateTypeName nm <*> mapM updateType tys
153+ updateType (ConstrainedType cs t) =
150− updateType (ConstrainedType cs t) = liftM (`ConstrainedType` t) $ updateConstraints cs
154+ ConstrainedType <$> updateConstraints cs <*> pure t
151 updateType t = return t
155 updateType t = return t
152 updateConstraints = mapM updateConstraint
156 updateConstraints = mapM updateConstraint
153− updateConstraint (Qualified Nothing nm, ts) = do
157+ updateConstraint (Qualified Nothing nm, ts) = (,) <$> updateClassName nm <*> pure ts
154− nm' <- updateClassName nm
156 updateConstraint other = return other
158 updateConstraint other = return other
157 updateTypeName = update "type" importedTypes
159 updateTypeName = update "type" importedTypes
158 updateClassName = update "type class" importedTypeClasses
160 updateClassName = update "type class" importedTypeClasses