git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Use applicative rather than liftM
commit74376998e4d8e5a4718b356500a6c4b15422ab87 authorGary Burgess <gary.burgess@gmail.com> dateMon 3 Mar 2014, 11:55 (13 years ago) parentb0c35c6
1 file changed+11−9
src/Language/PureScript/Sugar/Names.hs+11−9
src/Language/PureScript/Sugar/Names.hs+11−9
@@ -23,7 +23,7 @@ import Data.Generics (extM, mkM, everywhereM)
2323import Data.Generics.Extras (mkS, extS, everywhereWithContextM')
2424
2525import Control.Applicative (Applicative(..), (<$>), (<*>))
26−import Control.Monad (forM_, unless, foldM, liftM)
26+import Control.Monad (forM_, unless, foldM)
2727
2828import qualified Data.Map as M
2929import qualified Data.Set as S
@@ -140,19 +140,21 @@ renameInModule imports (Module mn decls) =
140140 bindBinders :: [Ident] -> ([Binder], Maybe Guard, Value) -> Either String ([Ident], ([Binder], Maybe Guard, Value))
141141 bindBinders bound (bs, grd, val) = return (binderNames bs ++ bound, (bs, grd, val))
142142 updateDecl d = return d
143− updateValue (Constructor (Qualified Nothing nm)) = liftM Constructor $ updateDataConstructorName nm
143+ updateValue (Constructor (Qualified Nothing nm)) =
144+ Constructor <$> updateDataConstructorName nm
144145 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
146148 updateBinder v = return v
147− updateType (TypeConstructor (Qualified Nothing nm)) = liftM TypeConstructor $ updateTypeName nm
149+ updateType (TypeConstructor (Qualified Nothing nm)) =
150+ TypeConstructor <$> updateTypeName nm
148151 updateType (SaturatedTypeSynonym (Qualified Nothing nm) tys) =
149− SaturatedTypeSynonym <$> updateTypeName nm <*> mapM updateType tys
150− updateType (ConstrainedType cs t) = liftM (`ConstrainedType` t) $ updateConstraints cs
152+ SaturatedTypeSynonym <$> updateTypeName nm <*> mapM updateType tys
153+ updateType (ConstrainedType cs t) =
154+ ConstrainedType <$> updateConstraints cs <*> pure t
151155 updateType t = return t
152156 updateConstraints = mapM updateConstraint
153− updateConstraint (Qualified Nothing nm, ts) = do
154− nm' <- updateClassName nm
155− return (nm', ts)
157+ updateConstraint (Qualified Nothing nm, ts) = (,) <$> updateClassName nm <*> pure ts
156158 updateConstraint other = return other
157159 updateTypeName = update "type" importedTypes
158160 updateClassName = update "type class" importedTypeClasses