git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Delinting
commit965df5c04f545075643c845af05a8169f07f5f00 authorGary Burgess <gary.burgess@gmail.com> dateThu 27 Feb 2014, 15:28 (13 years ago) parentc0eebf5
4 files changed+14−13
src/Language/PureScript/Sugar/Names.hs+5−5 src/Language/PureScript/TypeChecker.hs+3−3 src/Language/PureScript/TypeChecker/Synonyms.hs+5−4 src/Language/PureScript/TypeChecker/Types.hs+1−1
src/Language/PureScript/Sugar/Names.hs+5−5
@@ -17,7 +17,7 @@ module Language.PureScript.Sugar.Names (
1717) where
1818
1919import Control.Applicative ((<$>))
20−import Control.Monad (foldM)
20+import Control.Monad (foldM, liftM)
2121import Data.Generics (extM, mkM, everywhereM)
2222import qualified Data.Map as M
2323import qualified Data.Set as S
@@ -67,16 +67,16 @@ renameInModule imports (Module mn decls) =
6767 cs' <- updateConstraints cs
6868 return $ TypeInstanceDeclaration cs' cn' ts ds
6969 updateDecl d = return d
70− updateValue (Constructor (Qualified Nothing nm)) = updateDataConstructorName nm >>= return . Constructor
70+ updateValue (Constructor (Qualified Nothing nm)) = liftM Constructor $ updateDataConstructorName nm
7171 updateValue v = return v
72− updateBinder (ConstructorBinder (Qualified Nothing nm) b) = updateDataConstructorName nm >>= return . (`ConstructorBinder` b)
72+ updateBinder (ConstructorBinder (Qualified Nothing nm) b) = liftM (`ConstructorBinder` b) $ updateDataConstructorName nm
7373 updateBinder v = return v
74− updateType (TypeConstructor (Qualified Nothing nm)) = updateTypeName nm >>= return . TypeConstructor
74+ updateType (TypeConstructor (Qualified Nothing nm)) = liftM TypeConstructor $ updateTypeName nm
7575 updateType (SaturatedTypeSynonym (Qualified Nothing nm) tys) = do
7676 nm' <- updateTypeName nm
7777 tys' <- mapM updateType tys
7878 return $ SaturatedTypeSynonym nm' tys'
79− updateType (ConstrainedType cs t) = updateConstraints cs >>= return . (`ConstrainedType` t)
79+ updateType (ConstrainedType cs t) = liftM (`ConstrainedType` t) $ updateConstraints cs
8080 updateType t = return t
8181 updateConstraints = mapM updateConstraint
8282 updateConstraint (Qualified Nothing nm, ts) = do
src/Language/PureScript/TypeChecker.hs+3−3
@@ -209,16 +209,16 @@ typeCheckAll mainModuleName currentModule (d@(ImportDeclaration moduleName ident
209209 Nothing -> throwError (show moduleName ++ "." ++ show ident ++ " is undefined")
210210 shadowTypes pns env =
211211 forM_ pns $ \pn ->
212− case (Qualified (Just moduleName) pn) `M.lookup` types env of
212+ case Qualified (Just moduleName) pn `M.lookup` types env of
213213 Nothing -> throwError (show moduleName ++ "." ++ show pn ++ " is undefined")
214214 Just (_, DataAlias _ _) -> return ()
215215 Just (k, _) -> do
216− guardWith (show currentModule ++ "." ++ show pn ++ " is already defined") $ (Qualified (Just currentModule) pn) `M.notMember` types env
216+ guardWith (show currentModule ++ "." ++ show pn ++ " is already defined") $ Qualified (Just currentModule) pn `M.notMember` types env
217217 modifyEnv (\e -> e { types = M.insert (Qualified (Just currentModule) pn) (k, DataAlias moduleName pn) (types e) })
218218 let keys = map fst . filter (\(_, fn) -> fn `constructs` pn) . M.toList . dataConstructors $ env
219219 forM_ keys $ \dctor ->
220220 case dctor `M.lookup` dataConstructors env of
221− Just ctorTy -> do
221+ Just ctorTy ->
222222 modifyEnv (\e -> e { dataConstructors = M.insert dctor ctorTy (dataConstructors e) })
223223 Nothing -> throwError (show moduleName ++ "." ++ show dctor ++ " is undefined")
224224 shadowTypeClassInstances env = do
src/Language/PureScript/TypeChecker/Synonyms.hs+5−4
@@ -22,6 +22,7 @@ import Language.PureScript.Types
2222import Language.PureScript.Names
2323import Language.PureScript.TypeChecker.Monad (Environment(..))
2424
25+import Control.Applicative ((<$>))
2526import Data.Maybe (fromMaybe)
2627import Data.Data
2728import Data.Generics
@@ -32,7 +33,7 @@ import Control.Monad.Error
3233-- |
3334-- Build a type substitution for a type synonym
3435--
35−buildTypeSubstitution :: Environment -> ModuleName -> (Qualified ProperName) -> Int -> Type -> Either String (Maybe Type)
36+buildTypeSubstitution :: Environment -> ModuleName -> Qualified ProperName -> Int -> Type -> Either String (Maybe Type)
3637buildTypeSubstitution env moduleName name n = go n []
3738 where
3839 go :: Int -> [Type] -> Type -> Either String (Maybe Type)
@@ -44,15 +45,15 @@ buildTypeSubstitution env moduleName name n = go n []
4445-- |
4546-- Replace all instances of a specific type synonym with the @SaturatedTypeSynonym@ data constructor
4647--
47−saturateTypeSynonym :: (Data d) => Environment -> ModuleName -> (Qualified ProperName) -> Int -> d -> Either String d
48+saturateTypeSynonym :: (Data d) => Environment -> ModuleName -> Qualified ProperName -> Int -> d -> Either String d
4849saturateTypeSynonym env moduleName name n = everywhereM' (mkM replace)
4950 where
50− replace t = fmap (fromMaybe t) $ buildTypeSubstitution env moduleName name n t
51+ replace t = fromMaybe t <$> buildTypeSubstitution env moduleName name n t
5152
5253-- |
5354-- Replace all type synonyms with the @SaturatedTypeSynonym@ data constructor
5455--
55−saturateAllTypeSynonyms :: (Data d) => Environment -> ModuleName -> [((Qualified ProperName), Int)] -> d -> Either String d
56+saturateAllTypeSynonyms :: (Data d) => Environment -> ModuleName -> [(Qualified ProperName, Int)] -> d -> Either String d
5657saturateAllTypeSynonyms env moduleName syns d = foldM (\result (name, n) -> saturateTypeSynonym env moduleName name n result) d syns
5758
5859
src/Language/PureScript/TypeChecker/Types.hs+1−1
@@ -265,7 +265,7 @@ entails moduleName context goal@(className, tys) = do
265265 -- Choose type class dictionaries in scope in the current module
266266 , filterModule tcd
267267 -- Make sure the type class name matches the one we are trying to satisfy
268− , className' == (tcdClassName tcd)
268+ , className' == tcdClassName tcd
269269 -- Make sure the type unifies with the type in the type instance definition
270270 , subst <- maybeToList . (>>= verifySubstitution) . fmap concat $ zipWithM (typeHeadsAreEqual moduleName env) tys' (tcdInstanceTypes tcd)
271271 -- Solve any necessary subgoals