git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix most HLint warnings

This leaves in place 10 warnings, mostly for reducing duplication.

commit0b07beb08d68b3ae1c77d645f85ef681cc260b9d authorIan D. Bollinger <ian.bollinger@gmail.com> dateWed 17 Aug 2016, 18:23 (10 years ago) parent8dab1e8
25 files changed+50−53
hierarchy/Main.hs+1−1 psc/Main.hs+4−4 psci/Main.hs+3−3 src/Language/PureScript/Bundle.hs+5−5 src/Language/PureScript/CodeGen/JS.hs+1−1 src/Language/PureScript/Ide/Reexports.hs−2 src/Language/PureScript/Ide/State.hs+1−1 src/Language/PureScript/Ide/Util.hs+1−1 src/Language/PureScript/Interactive/Completion.hs+1−1 src/Language/PureScript/Interactive/Printer.hs+1−1 src/Language/PureScript/Interactive/Types.hs+2−2 src/Language/PureScript/Pretty/Common.hs+1−1 src/Language/PureScript/Publish/ErrorsWarnings.hs+8−8 src/Language/PureScript/Renamer.hs+3−3 src/Language/PureScript/Sugar/ObjectWildcards.hs+1−1 src/Language/PureScript/Sugar/Operators/Common.hs+2−2 src/Language/PureScript/Sugar/Operators/Expr.hs+1−1 src/Language/PureScript/Sugar/TypeClasses/Deriving.hs+1−1 src/Language/PureScript/TypeChecker/Monad.hs+1−1 src/Language/PureScript/TypeChecker/Subsumption.hs+1−1 src/Language/PureScript/TypeChecker/Types.hs+1−1 tests/Language/PureScript/Ide/ReexportsSpec.hs+1−1 tests/Language/PureScript/Ide/SourceFile/IntegrationSpec.hs+8−8 tests/Language/PureScript/Ide/SourceFileSpec.hs+1−1 tests/TestPsci.hs−1
hierarchy/Main.hs+1−1
@@ -40,7 +40,7 @@ data HierarchyOptions = HierarchyOptions
4040 , hierarchyOutput :: Maybe FilePath
4141 }
4242
43−newtype SuperMap = SuperMap { unSuperMap :: Either (P.ProperName 'P.ClassName) ((P.ProperName 'P.ClassName), (P.ProperName 'P.ClassName)) }
43+newtype SuperMap = SuperMap { unSuperMap :: Either (P.ProperName 'P.ClassName) (P.ProperName 'P.ClassName, P.ProperName 'P.ClassName) }
4444 deriving Eq
4545
4646instance Show SuperMap where
psc/Main.hs+4−4
@@ -79,11 +79,11 @@ warnFileTypeNotFound = hPutStrLn stderr . ("psc: No files found using pattern: "
7979globWarningOnMisses :: (String -> IO ()) -> [FilePath] -> IO [FilePath]
8080globWarningOnMisses warn = concatMapM globWithWarning
8181 where
82− globWithWarning pattern = do
83− paths <- glob pattern
84− when (null paths) $ warn pattern
82+ globWithWarning pattern' = do
83+ paths <- glob pattern'
84+ when (null paths) $ warn pattern'
8585 return paths
86− concatMapM f = liftM concat . mapM f
86+ concatMapM f = fmap concat . mapM f
8787
8888readInput :: [FilePath] -> IO [(FilePath, String)]
8989readInput inputFiles = forM inputFiles $ \inFile -> (inFile, ) <$> readUTF8File inFile
psci/Main.hs+3−3
@@ -207,7 +207,7 @@ browserBackend serverPort = Backend setup evaluate reload shutdown
207207 -- With many connected clients, all but one of
208208 -- these attempts will fail.
209209 tryPutMVar resultVar (unpack result)
210− Reload -> do
210+ Reload ->
211211 WS.sendTextData conn ("reload" :: Text)
212212
213213 shutdownHandler :: IO () -> IO ()
@@ -278,7 +278,7 @@ browserBackend serverPort = Backend setup evaluate reload shutdown
278278 Left err -> do
279279 putStrLn (unlines (Bundle.printErrorMessage err))
280280 exitFailure
281− Right js -> do
281+ Right js ->
282282 atomically $ writeTVar (browserBundleJS state) (Just js)
283283
284284 reload :: BrowserState -> IO ()
@@ -335,7 +335,7 @@ main = getOpt >>= loop
335335 (externs, env) <- ExceptT . runMake . make $ modules
336336 return (modules, externs, env)
337337 case psciBackend of
338− Backend setup eval reload (shutdown :: state -> IO ()) -> do
338+ Backend setup eval reload (shutdown :: state -> IO ()) ->
339339 case e of
340340 Left errs -> putStrLn (P.prettyPrintMultipleErrors P.defaultPPEOptions errs) >> exitFailure
341341 Right (modules, externs, env) -> do
src/Language/PureScript/Bundle.hs+5−5
@@ -256,7 +256,7 @@ toModule mids mid top
256256 = pure (Member stmt exported name decl [])
257257 toModuleElement stmt
258258 | Just props <- matchExportsAssignment stmt
259− = (ExportsList <$> traverse toExport (trailingCommaList props))
259+ = ExportsList <$> traverse toExport (trailingCommaList props)
260260 where
261261 toExport :: JSObjectProperty -> m (ExportType, String, JSExpression, [Key])
262262 toExport (JSPropertyNameandValue name _ [val]) =
@@ -524,7 +524,7 @@ codeGen optionsMainModule optionsNamespace ms = renderToString (JSAstProgram (p
524524 indent :: [JSStatement] -> [JSStatement]
525525 indent = everywhere (mkT squash)
526526 where
527− squash JSNoAnnot = (JSAnnot (TokenPn 0 0 2) [])
527+ squash JSNoAnnot = JSAnnot (TokenPn 0 0 2) []
528528 squash (JSAnnot pos ann) = JSAnnot (keepCol pos) (map splat ann)
529529
530530 splat (CommentA pos s) = CommentA (keepCol pos) s
@@ -571,15 +571,15 @@ codeGen optionsMainModule optionsNamespace ms = renderToString (JSAstProgram (p
571571 (JSSemi JSNoAnnot)
572572 ]
573573 where
574− lfHead (h:t) = (addAnn (WhiteSpace tokenPosnEmpty "\n ") h) : t
574+ lfHead (h:t) = addAnn (WhiteSpace tokenPosnEmpty "\n ") h : t
575575 lfHead x = x
576576
577577 addAnn :: CommentAnnotation -> JSStatement -> JSStatement
578578 addAnn a (JSExpressionStatement (JSStringLiteral ann s) _) =
579− (JSExpressionStatement (JSStringLiteral (appendAnn a ann) s) (JSSemi JSNoAnnot))
579+ JSExpressionStatement (JSStringLiteral (appendAnn a ann) s) (JSSemi JSNoAnnot)
580580 addAnn _ x = x
581581
582− appendAnn a JSNoAnnot = (JSAnnot tokenPosnEmpty [a])
582+ appendAnn a JSNoAnnot = JSAnnot tokenPosnEmpty [a]
583583 appendAnn a (JSAnnot _ anns) = JSAnnot tokenPosnEmpty (a:anns ++ [WhiteSpace tokenPosnEmpty " "])
584584
585585 runMain :: String -> [JSStatement]
src/Language/PureScript/CodeGen/JS.hs+1−1
@@ -367,7 +367,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
367367 -- binder.
368368 --
369369 binderToJs' :: String -> [JS] -> Binder Ann -> m [JS]
370− binderToJs' _ done (NullBinder{}) = return done
370+ binderToJs' _ done NullBinder{} = return done
371371 binderToJs' varName done (LiteralBinder _ l) =
372372 literalToBinderJS varName done l
373373 binderToJs' varName done (VarBinder _ ident) =
src/Language/PureScript/Ide/Reexports.hs−2
@@ -14,8 +14,6 @@
1414-----------------------------------------------------------------------------
1515
1616{-# LANGUAGE OverloadedStrings #-}
17−{-# LANGUAGE PackageImports #-}
18−{-# LANGUAGE TemplateHaskell #-}
1917{-# LANGUAGE RecordWildCards #-}
2018
2119module Language.PureScript.Ide.Reexports
src/Language/PureScript/Ide/State.hs+1−1
@@ -180,7 +180,7 @@ populateStage2 = do
180180populateStage2STM :: TVar IdeState -> STM ()
181181populateStage2STM ref = do
182182 modules <- s1Modules <$> getStage1STM ref
183− let spans = map (\((P.Module ss _ _ decls _), _) -> M.fromList (concatMap (extractSpans ss) decls)) modules
183+ let spans = map (\(P.Module ss _ _ decls _, _) -> M.fromList (concatMap (extractSpans ss) decls)) modules
184184 setStage2STM ref (Stage2 (AstData spans))
185185
186186-- | Resolves reexports and populates Stage3 with data to be used in queries.
src/Language/PureScript/Ide/Util.hs+1−1
@@ -75,7 +75,7 @@ completionFromMatch' (Match (m', d)) = case d of
7575 in T.unwords [asso, show p, r, "as", runOpNameT o]
7676
7777infoFromMatch :: Match IdeDeclarationAnn -> Info
78−infoFromMatch (Match (m, (IdeDeclarationAnn ann d))) =
78+infoFromMatch (Match (m, IdeDeclarationAnn ann d)) =
7979 Info (a, b, c, annLocation ann)
8080 where
8181 (a, b, c) = completionFromMatch' (Match (m, d))
src/Language/PureScript/Interactive/Completion.hs+1−1
@@ -214,7 +214,7 @@ dctorNames :: P.Module -> [(N.ProperName 'N.ConstructorName, P.Declaration)]
214214dctorNames = nubOnFst . concatMap go . P.exportedDeclarations
215215 where
216216 go :: P.Declaration -> [(N.ProperName 'N.ConstructorName, P.Declaration)]
217− go decl@(P.DataDeclaration _ _ _ ctors) = map (\n -> (n, decl)) (map fst ctors)
217+ go decl@(P.DataDeclaration _ _ _ ctors) = map ((\n -> (n, decl)) . fst) ctors
218218 go (P.PositionedDeclaration _ _ d) = go d
219219 go _ = []
220220
src/Language/PureScript/Interactive/Printer.hs+1−1
@@ -17,7 +17,7 @@ import qualified Text.PrettyPrint.Boxes as Box
1717-- Pretty print a module's signatures
1818--
1919printModuleSignatures :: P.ModuleName -> P.Environment -> String
20−printModuleSignatures moduleName (P.Environment {..}) =
20+printModuleSignatures moduleName P.Environment{..} =
2121 -- get relevant components of a module from environment
2222 let moduleNamesIdent = byModuleName names
2323 moduleTypeClasses = byModuleName typeClasses
src/Language/PureScript/Interactive/Types.hs+2−2
@@ -42,11 +42,11 @@ initialPSCiState = PSCiState [] [] []
4242type ImportedModule = (P.ModuleName, P.ImportDeclarationType, Maybe P.ModuleName)
4343
4444psciImportedModuleNames :: PSCiState -> [P.ModuleName]
45−psciImportedModuleNames (PSCiState{psciImportedModules = is}) =
45+psciImportedModuleNames PSCiState{psciImportedModules = is} =
4646 map (\(mn, _, _) -> mn) is
4747
4848allImportsOf :: P.Module -> PSCiState -> [ImportedModule]
49−allImportsOf m (PSCiState{psciImportedModules = is}) =
49+allImportsOf m PSCiState{psciImportedModules = is} =
5050 filter isImportOfThis is
5151 where
5252 name = P.getModuleName m
src/Language/PureScript/Pretty/Common.hs+1−1
@@ -74,7 +74,7 @@ instance Emit StrPos where
7474 -- |
7575 -- Add a new mapping entry for given source position with initially zero generated position
7676 --
77− addMapping (SourceSpan { spanName = file, spanStart = startPos }) = StrPos (zeroPos, mempty, [mapping])
77+ addMapping SourceSpan { spanName = file, spanStart = startPos } = StrPos (zeroPos, mempty, [mapping])
7878 where
7979 mapping = SMap file startPos zeroPos
8080 zeroPos = SourcePos 0 0
src/Language/PureScript/Publish/ErrorsWarnings.hs+8−8
@@ -182,10 +182,10 @@ displayUserError e = case e of
182182 , spacer
183183 ] ++ spdxExamples ++
184184 [ spacer
185− , para (concat
186− [ "Note that distributing code without a license means that nobody "
187− , "will (legally) be able to use it."
188− ])
185+ , para (
186+ "Note that distributing code without a license means that nobody "
187+ ++ "will (legally) be able to use it."
188+ )
189189 , spacer
190190 , para (concat
191191 [ "It is also recommended to add a LICENSE file to the repository, "
@@ -420,10 +420,10 @@ warnUnacceptableVersions pkgs =
420420
421421warnDirtyWorkingTree :: Box
422422warnDirtyWorkingTree =
423− para (concat
424− [ "Your working tree is dirty. (Note: this would be an error if it "
425− , "were not a dry run)"
426− ])
423+ para (
424+ "Your working tree is dirty. (Note: this would be an error if it "
425+ ++ "were not a dry run)"
426+ )
427427
428428printWarnings :: [PackageWarning] -> IO ()
429429printWarnings = printToStderr . renderWarnings
src/Language/PureScript/Renamer.hs+3−3
@@ -142,7 +142,7 @@ renameInDecl isTopLevel (Rec ds) = do
142142renameInValue :: Expr Ann -> Rename (Expr Ann)
143143renameInValue (Literal ann l) =
144144 Literal ann <$> renameInLiteral renameInValue l
145−renameInValue c@(Constructor{}) = return c
145+renameInValue c@Constructor{} = return c
146146renameInValue (Accessor ann prop v) =
147147 Accessor ann prop <$> renameInValue v
148148renameInValue (ObjectUpdate ann obj vs) =
@@ -154,7 +154,7 @@ renameInValue (App ann v1 v2) =
154154 App ann <$> renameInValue v1 <*> renameInValue v2
155155renameInValue (Var ann (Qualified Nothing name)) =
156156 Var ann . Qualified Nothing <$> lookupIdent name
157−renameInValue v@(Var{}) = return v
157+renameInValue v@Var{} = return v
158158renameInValue (Case ann vs alts) =
159159 newScope $ Case ann <$> traverse renameInValue vs <*> traverse renameInCaseAlternative alts
160160renameInValue (Let ann ds v) =
@@ -180,7 +180,7 @@ renameInCaseAlternative (CaseAlternative bs v) = newScope $
180180-- Renames within binders.
181181--
182182renameInBinder :: Binder a -> Rename (Binder a)
183−renameInBinder n@(NullBinder{}) = return n
183+renameInBinder n@NullBinder{} = return n
184184renameInBinder (LiteralBinder ann b) =
185185 LiteralBinder ann <$> renameInLiteral renameInBinder b
186186renameInBinder (VarBinder ann name) =
src/Language/PureScript/Sugar/ObjectWildcards.hs+1−1
@@ -50,7 +50,7 @@ desugarObjectConstructors (Module ss coms mn ds exts) = Module ss coms mn <$> ma
5050 return $ Abs (Left arg) (Accessor prop (argToExpr arg))
5151 desugarExpr (Case args cas) | any isAnonymousArgument args = do
5252 argIdents <- forM args freshIfAnon
53− let args' = zipWith (\p -> maybe p argToExpr) args argIdents
53+ let args' = zipWith (`maybe` argToExpr) args argIdents
5454 return $ foldr (Abs . Left) (Case args' cas) (catMaybes argIdents)
5555 desugarExpr (IfThenElse u t f) | any isAnonymousArgument [u, t, f] = do
5656 u' <- freshIfAnon u
src/Language/PureScript/Sugar/Operators/Common.hs+2−2
@@ -28,12 +28,12 @@ parseValue :: P.Parsec (Chain a) () a
2828parseValue = token (either Just (const Nothing)) P.<?> "expression"
2929
3030parseOp
31− :: (a -> (Maybe (Qualified (OpName nameType))))
31+ :: (a -> Maybe (Qualified (OpName nameType)))
3232 -> P.Parsec (Chain a) () (Qualified (OpName nameType))
3333parseOp fromOp = token (either (const Nothing) fromOp) P.<?> "operator"
3434
3535matchOp
36− :: (a -> (Maybe (Qualified (OpName nameType))))
36+ :: (a -> Maybe (Qualified (OpName nameType)))
3737 -> Qualified (OpName nameType)
3838 -> P.Parsec (Chain a) () ()
3939matchOp fromOp op = do
src/Language/PureScript/Sugar/Operators/Expr.hs+1−1
@@ -28,7 +28,7 @@ matchExprOperators = matchOperators isBinOp extractOp fromOp reapply modOpTable
2828 fromOp _ = Nothing
2929
3030 reapply :: Qualified (OpName 'ValueOpName) -> Expr -> Expr -> Expr
31− reapply op t1 t2 = App (App (Op op) t1) t2
31+ reapply op t1 = App (App (Op op) t1)
3232
3333 modOpTable
3434 :: [[P.Operator (Chain Expr) () Identity Expr]]
src/Language/PureScript/Sugar/TypeClasses/Deriving.hs+1−1
@@ -223,7 +223,7 @@ deriveGeneric mn ds tyConNm dargs = do
223223 $ liftApplicative (mkRecFun rs) (map (\(x, y) -> fromSpineFun (Accessor "recValue" (mkVar (Ident x))) y) rs)
224224
225225 mkRecFun :: [(String, Type)] -> Expr
226− mkRecFun xs = mkJust $ foldr lam recLiteral (map (Ident . fst) xs)
226+ mkRecFun xs = mkJust $ foldr (lam . Ident . fst) recLiteral xs
227227 where recLiteral = Literal . ObjectLiteral $ map (\(s,_) -> (s, mkVar (Ident s))) xs
228228 mkFromSpineFunction (PositionedDeclaration _ _ d) = mkFromSpineFunction d
229229 mkFromSpineFunction _ = internalError "mkFromSpineFunction: expected DataDeclaration"
src/Language/PureScript/TypeChecker/Monad.hs+1−1
@@ -245,7 +245,7 @@ getEnv = checkEnv <$> get
245245getLocalContext :: MonadState CheckState m => m Context
246246getLocalContext = do
247247 env <- getEnv
248− return [ (ident, ty') | ((Qualified Nothing ident@Ident{}), (ty', _, Defined)) <- M.toList (names env) ]
248+ return [ (ident, ty') | (Qualified Nothing ident@Ident{}, (ty', _, Defined)) <- M.toList (names env) ]
249249
250250-- | Update the @Environment@
251251putEnv :: (MonadState CheckState m) => Environment -> m ()
src/Language/PureScript/TypeChecker/Subsumption.hs+1−1
@@ -89,7 +89,7 @@ subsumes' val (TypeApp f1 r1) (TypeApp f2 r2) | f1 == tyRecord && f2 == tyRecord
8989 unifyTypes r1' (RCons p2 ty2 rest)
9090 go ((p1, ty1) : ts1) ts2 rest r2'
9191 -- Find the first property that's in the first list (of tuples) but not in the second
92− firstMissingProp t1 t2 = fst <$> (uncons $ minusBy' (comparing fst) t1 t2)
92+ firstMissingProp t1 t2 = fst <$> uncons (minusBy' (comparing fst) t1 t2)
9393subsumes' val ty1 ty2@(TypeApp obj _) | obj == tyRecord = subsumes val ty2 ty1
9494subsumes' val ty1 ty2 = do
9595 unifyTypes ty1 ty2
src/Language/PureScript/TypeChecker/Types.hs+1−1
@@ -148,7 +148,7 @@ typeDictionaryForBindingGroup moduleName vals = do
148148 -- Make a map of names to the unification variables of untyped declarations
149149 untypedDict = zip (map fst untyped) untypedNames
150150 -- Create the dictionary of all name/type pairs, which will be added to the environment during type checking
151− dict = M.fromList (map (\(ident, ty) -> ((Qualified moduleName ident), (ty, Private, Undefined))) $ typedDict ++ untypedDict)
151+ dict = M.fromList (map (\(ident, ty) -> (Qualified moduleName ident, (ty, Private, Undefined))) $ typedDict ++ untypedDict)
152152 return (untyped, typed, dict, untypedDict)
153153
154154checkTypedBindingGroupElement
tests/Language/PureScript/Ide/ReexportsSpec.hs+1−1
@@ -2,7 +2,7 @@
22{-# LANGUAGE NoImplicitPrelude #-}
33module Language.PureScript.Ide.ReexportsSpec where
44
5−import qualified Prelude as Prelude
5+import qualified Prelude
66import Protolude
77
88import qualified Data.Map as Map
tests/Language/PureScript/Ide/SourceFile/IntegrationSpec.hs+8−8
@@ -14,23 +14,23 @@ setup :: IO ()
1414setup = void (Integration.reset *> Integration.loadAll)
1515
1616spec :: Spec
17−spec = beforeAll_ setup $ do
17+spec = beforeAll_ setup $
1818 describe "Sourcefile Integration" $ do
19− it "finds a value declaration" $ do
19+ it "finds a value declaration" $
2020 testCase "sfValue" (3, 1)
21− it "finds a type declaration" $ do
21+ it "finds a type declaration" $
2222 testCase "SFType" (5, 1)
23− it "finds a data declaration" $ do
23+ it "finds a data declaration" $
2424 testCase "SFData" (7, 1)
25− it "finds a data constructor" $ do
25+ it "finds a data constructor" $
2626 testCase "SFOne" (7, 1)
27− it "finds a typeclass" $ do
27+ it "finds a typeclass" $
2828 testCase "SFClass" (9, 1)
29− it "finds a typeclass member" $ do
29+ it "finds a typeclass member" $
3030 testCase "sfShow" (10, 3)
3131
3232testCase :: Text -> (Int, Int) -> IO ()
3333testCase s (x, y) = do
34− (P.SourceSpan f (P.SourcePos l c) _):_ <- Integration.getInfo s
34+ P.SourceSpan f (P.SourcePos l c) _ : _ <- Integration.getInfo s
3535 toS f `shouldSatisfy` T.isSuffixOf "SourceFileSpec.purs"
3636 (l, c) `shouldBe` (x, y)
tests/Language/PureScript/Ide/SourceFileSpec.hs+1−1
@@ -26,7 +26,7 @@ foreign2 = P.ExternDataDeclaration (P.ProperName "Foreign2") P.Star
2626member1 = P.TypeDeclaration (P.Ident "member1") P.REmpty
2727
2828spec :: Spec
29−spec = do
29+spec =
3030 describe "Extracting Spans" $ do
3131 it "extracts a span for a value declaration" $
3232 extractSpans span0 (P.PositionedDeclaration span1 [] value1) `shouldBe` [(Left "value1", span1)]
tests/TestPsci.hs−1
@@ -102,7 +102,6 @@ completionTestData =
102102 , ("ST.new", ["ST.newSTRef"])
103103 , ("Control.Monad.ST.new", ["Control.Monad.ST.newSTRef"])
104104 ]
105− where
106105
107106assertCompletedOk :: (String, [String]) -> Assertion
108107assertCompletedOk (line, expecteds) = do