git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Delinting
965df5cGary Burgess
src/Language/PureScript/Sugar/Names.hs+5−5
@@ -17,7 +17,7 @@ module Language.PureScript.Sugar.Names (
17) where
17) where
18
18
19import Control.Applicative ((<$>))
19import Control.Applicative ((<$>))
20−import Control.Monad (foldM)
20+import Control.Monad (foldM, liftM)
21import Data.Generics (extM, mkM, everywhereM)
21import Data.Generics (extM, mkM, everywhereM)
22import qualified Data.Map as M
22import qualified Data.Map as M
23import qualified Data.Set as S
23import qualified Data.Set as S
@@ -67,16 +67,16 @@ renameInModule imports (Module mn decls) =
67 cs' <- updateConstraints cs
67 cs' <- updateConstraints cs
68 return $ TypeInstanceDeclaration cs' cn' ts ds
68 return $ TypeInstanceDeclaration cs' cn' ts ds
69 updateDecl d = return d
69 updateDecl d = return d
70− updateValue (Constructor (Qualified Nothing nm)) = updateDataConstructorName nm >>= return . Constructor
70+ updateValue (Constructor (Qualified Nothing nm)) = liftM Constructor $ updateDataConstructorName nm
71 updateValue v = return v
71 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
73 updateBinder v = return v
73 updateBinder v = return v
74− updateType (TypeConstructor (Qualified Nothing nm)) = updateTypeName nm >>= return . TypeConstructor
74+ updateType (TypeConstructor (Qualified Nothing nm)) = liftM TypeConstructor $ updateTypeName nm
75 updateType (SaturatedTypeSynonym (Qualified Nothing nm) tys) = do
75 updateType (SaturatedTypeSynonym (Qualified Nothing nm) tys) = do
76 nm' <- updateTypeName nm
76 nm' <- updateTypeName nm
77 tys' <- mapM updateType tys
77 tys' <- mapM updateType tys
78 return $ SaturatedTypeSynonym nm' tys'
78 return $ SaturatedTypeSynonym nm' tys'
79− updateType (ConstrainedType cs t) = updateConstraints cs >>= return . (`ConstrainedType` t)
79+ updateType (ConstrainedType cs t) = liftM (`ConstrainedType` t) $ updateConstraints cs
80 updateType t = return t
80 updateType t = return t
81 updateConstraints = mapM updateConstraint
81 updateConstraints = mapM updateConstraint
82 updateConstraint (Qualified Nothing nm, ts) = do
82 updateConstraint (Qualified Nothing nm, ts) = do
src/Language/PureScript/TypeChecker.hs+3−3
@@ -209,16 +209,16 @@ typeCheckAll mainModuleName currentModule (d@(ImportDeclaration moduleName ident
209 Nothing -> throwError (show moduleName ++ "." ++ show ident ++ " is undefined")
209 Nothing -> throwError (show moduleName ++ "." ++ show ident ++ " is undefined")
210 shadowTypes pns env =
210 shadowTypes pns env =
211 forM_ pns $ \pn ->
211 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
213 Nothing -> throwError (show moduleName ++ "." ++ show pn ++ " is undefined")
213 Nothing -> throwError (show moduleName ++ "." ++ show pn ++ " is undefined")
214 Just (_, DataAlias _ _) -> return ()
214 Just (_, DataAlias _ _) -> return ()
215 Just (k, _) -> do
215 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
217 modifyEnv (\e -> e { types = M.insert (Qualified (Just currentModule) pn) (k, DataAlias moduleName pn) (types e) })
217 modifyEnv (\e -> e { types = M.insert (Qualified (Just currentModule) pn) (k, DataAlias moduleName pn) (types e) })
218 let keys = map fst . filter (\(_, fn) -> fn `constructs` pn) . M.toList . dataConstructors $ env
218 let keys = map fst . filter (\(_, fn) -> fn `constructs` pn) . M.toList . dataConstructors $ env
219 forM_ keys $ \dctor ->
219 forM_ keys $ \dctor ->
220 case dctor `M.lookup` dataConstructors env of
220 case dctor `M.lookup` dataConstructors env of
221− Just ctorTy -> do
221+ Just ctorTy ->
222 modifyEnv (\e -> e { dataConstructors = M.insert dctor ctorTy (dataConstructors e) })
222 modifyEnv (\e -> e { dataConstructors = M.insert dctor ctorTy (dataConstructors e) })
223 Nothing -> throwError (show moduleName ++ "." ++ show dctor ++ " is undefined")
223 Nothing -> throwError (show moduleName ++ "." ++ show dctor ++ " is undefined")
224 shadowTypeClassInstances env = do
224 shadowTypeClassInstances env = do
src/Language/PureScript/TypeChecker/Synonyms.hs+5−4
@@ -22,6 +22,7 @@ import Language.PureScript.Types
22import Language.PureScript.Names
22import Language.PureScript.Names
23import Language.PureScript.TypeChecker.Monad (Environment(..))
23import Language.PureScript.TypeChecker.Monad (Environment(..))
24
24
25+import Control.Applicative ((<$>))
25import Data.Maybe (fromMaybe)
26import Data.Maybe (fromMaybe)
26import Data.Data
27import Data.Data
27import Data.Generics
28import Data.Generics
@@ -32,7 +33,7 @@ import Control.Monad.Error
32-- |
33-- |
33-- Build a type substitution for a type synonym
34-- Build a type substitution for a type synonym
34--
35--
35−buildTypeSubstitution :: Environment -> ModuleName -> (Qualified ProperName) -> Int -> Type -> Either String (Maybe Type)
36+buildTypeSubstitution :: Environment -> ModuleName -> Qualified ProperName -> Int -> Type -> Either String (Maybe Type)
36buildTypeSubstitution env moduleName name n = go n []
37buildTypeSubstitution env moduleName name n = go n []
37 where
38 where
38 go :: Int -> [Type] -> Type -> Either String (Maybe Type)
39 go :: Int -> [Type] -> Type -> Either String (Maybe Type)
@@ -44,15 +45,15 @@ buildTypeSubstitution env moduleName name n = go n []
44-- |
45-- |
45-- Replace all instances of a specific type synonym with the @SaturatedTypeSynonym@ data constructor
46-- Replace all instances of a specific type synonym with the @SaturatedTypeSynonym@ data constructor
46--
47--
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
48saturateTypeSynonym env moduleName name n = everywhereM' (mkM replace)
49saturateTypeSynonym env moduleName name n = everywhereM' (mkM replace)
49 where
50 where
50− replace t = fmap (fromMaybe t) $ buildTypeSubstitution env moduleName name n t
51+ replace t = fromMaybe t <$> buildTypeSubstitution env moduleName name n t
51
52
52-- |
53-- |
53-- Replace all type synonyms with the @SaturatedTypeSynonym@ data constructor
54-- Replace all type synonyms with the @SaturatedTypeSynonym@ data constructor
54--
55--
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
56saturateAllTypeSynonyms env moduleName syns d = foldM (\result (name, n) -> saturateTypeSynonym env moduleName name n result) d syns
57saturateAllTypeSynonyms env moduleName syns d = foldM (\result (name, n) -> saturateTypeSynonym env moduleName name n result) d syns
57
58
58
59
src/Language/PureScript/TypeChecker/Types.hs+1−1
@@ -265,7 +265,7 @@ entails moduleName context goal@(className, tys) = do
265 -- Choose type class dictionaries in scope in the current module
265 -- Choose type class dictionaries in scope in the current module
266 , filterModule tcd
266 , filterModule tcd
267 -- Make sure the type class name matches the one we are trying to satisfy
267 -- Make sure the type class name matches the one we are trying to satisfy
268− , className' == (tcdClassName tcd)
268+ , className' == tcdClassName tcd
269 -- Make sure the type unifies with the type in the type instance definition
269 -- Make sure the type unifies with the type in the type instance definition
270 , subst <- maybeToList . (>>= verifySubstitution) . fmap concat $ zipWithM (typeHeadsAreEqual moduleName env) tys' (tcdInstanceTypes tcd)
270 , subst <- maybeToList . (>>= verifySubstitution) . fmap concat $ zipWithM (typeHeadsAreEqual moduleName env) tys' (tcdInstanceTypes tcd)
271 -- Solve any necessary subgoals
271 -- Solve any necessary subgoals