cln: hlint: Clean up list related hlint warnings.
This commit is contained in:
		
							parent
							
								
									22db5c4a3f
								
							
						
					
					
						commit
						beecb3c9ac
					
				| @ -7,8 +7,6 @@ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # Warnings currently triggered by your code | # Warnings currently triggered by your code | ||||||
| - ignore: {name: "Use ++"} |  | ||||||
| - ignore: {name: "Use list literal"} |  | ||||||
| - ignore: {name: "Move brackets to avoid $"} | - ignore: {name: "Move brackets to avoid $"} | ||||||
| - ignore: {name: "Redundant $"} | - ignore: {name: "Redundant $"} | ||||||
| - ignore: {name: "Use <$>"} | - ignore: {name: "Use <$>"} | ||||||
| @ -24,17 +22,13 @@ | |||||||
| - ignore: {name: "Use camelCase"} | - ignore: {name: "Use camelCase"} | ||||||
| - ignore: {name: "Use list comprehension"} | - ignore: {name: "Use list comprehension"} | ||||||
| - ignore: {name: "Redundant <$>"} | - ignore: {name: "Redundant <$>"} | ||||||
| - ignore: {name: "Use list literal pattern"} |  | ||||||
| - ignore: {name: "Use fewer imports"} | - ignore: {name: "Use fewer imports"} | ||||||
| - ignore: {name: "Use tuple-section"} | - ignore: {name: "Use tuple-section"} | ||||||
| - ignore: {name: "Use section"} | - ignore: {name: "Use section"} | ||||||
| - ignore: {name: "Avoid lambda using `infix`"} | - ignore: {name: "Avoid lambda using `infix`"} | ||||||
| - ignore: {name: "Functor law"} | - ignore: {name: "Functor law"} | ||||||
| - ignore: {name: "Missing NOINLINE pragma"} | - ignore: {name: "Missing NOINLINE pragma"} | ||||||
| - ignore: {name: "Use dropWhile"} |  | ||||||
| - ignore: {name: "Use replicate"} |  | ||||||
| - ignore: {name: "Use void"} | - ignore: {name: "Use void"} | ||||||
| - ignore: {name: "Use elemIndex"} |  | ||||||
| - ignore: {name: "Use lambda-case"} | - ignore: {name: "Use lambda-case"} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										8
									
								
								Shake.hs
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								Shake.hs
									
									
									
									
									
								
							| @ -299,10 +299,8 @@ main = do | |||||||
|           Nothing -> return () |           Nothing -> return () | ||||||
| 
 | 
 | ||||||
|         -- update "source" files depending on .version in the specified packages |         -- update "source" files depending on .version in the specified packages | ||||||
|         let dependents = concat [ |         let dependents = map (</> ".version.m4")  specifiedpkgs | ||||||
|                map (</> ".version.m4")  specifiedpkgs |                       ++ map (</> "package.yaml") specifiedpkgs | ||||||
|               ,map (</> "package.yaml") specifiedpkgs |  | ||||||
|               ] |  | ||||||
|         need dependents |         need dependents | ||||||
| 
 | 
 | ||||||
|         -- and maybe commit them |         -- and maybe commit them | ||||||
| @ -333,7 +331,7 @@ main = do | |||||||
|         need [versionfile] |         need [versionfile] | ||||||
|         version <- ((head . words) <$>) $ liftIO $ readFile versionfile |         version <- ((head . words) <$>) $ liftIO $ readFile versionfile | ||||||
|         let ma:jor:_ = splitOn "." version |         let ma:jor:_ = splitOn "." version | ||||||
|             nextmajorversion = intercalate "." $ ma : (show $ read jor+1) : [] |             nextmajorversion = intercalate "." [ma, show $ read jor+1] | ||||||
| 
 | 
 | ||||||
|         -- One simple task: update some strings in a small text file. |         -- One simple task: update some strings in a small text file. | ||||||
|         -- Several ugly solutions: |         -- Several ugly solutions: | ||||||
|  | |||||||
| @ -50,7 +50,7 @@ setboolopt :: String -> RawOpts -> RawOpts | |||||||
| setboolopt name = overRawOpts (++ [(name,"")]) | setboolopt name = overRawOpts (++ [(name,"")]) | ||||||
| 
 | 
 | ||||||
| appendopts :: [(String,String)] -> RawOpts -> RawOpts | appendopts :: [(String,String)] -> RawOpts -> RawOpts | ||||||
| appendopts new = overRawOpts $ \old -> concat [old,new] | appendopts new = overRawOpts (++new) | ||||||
| 
 | 
 | ||||||
| -- | Is the named option present ? | -- | Is the named option present ? | ||||||
| inRawOpts :: String -> RawOpts -> Bool | inRawOpts :: String -> RawOpts -> Bool | ||||||
|  | |||||||
| @ -154,8 +154,8 @@ traceWith f a = trace (f a) a | |||||||
| -- {-# NOINLINE debugLevel #-} | -- {-# NOINLINE debugLevel #-} | ||||||
| -- Avoid using dbg* in this function (infinite loop). | -- Avoid using dbg* in this function (infinite loop). | ||||||
| debugLevel :: Int | debugLevel :: Int | ||||||
| debugLevel = case snd $ break (=="--debug") args of | debugLevel = case dropWhile (/="--debug") args of | ||||||
|                "--debug":[]  -> 1 |                ["--debug"]   -> 1 | ||||||
|                "--debug":n:_ -> readDef 1 n |                "--debug":n:_ -> readDef 1 n | ||||||
|                _             -> |                _             -> | ||||||
|                  case take 1 $ filter ("--debug" `isPrefixOf`) args of |                  case take 1 $ filter ("--debug" `isPrefixOf`) args of | ||||||
| @ -215,7 +215,7 @@ colorOption :: String | |||||||
| colorOption =  | colorOption =  | ||||||
|   -- similar to debugLevel |   -- similar to debugLevel | ||||||
|   let args = unsafePerformIO getArgs in |   let args = unsafePerformIO getArgs in | ||||||
|   case snd $ break (=="--color") args of |   case dropWhile (/="--color") args of | ||||||
|     -- --color ARG |     -- --color ARG | ||||||
|     "--color":v:_ -> v |     "--color":v:_ -> v | ||||||
|     _ -> |     _ -> | ||||||
| @ -223,7 +223,7 @@ colorOption = | |||||||
|         -- --color=ARG |         -- --color=ARG | ||||||
|         ['-':'-':'c':'o':'l':'o':'r':'=':v] -> v |         ['-':'-':'c':'o':'l':'o':'r':'=':v] -> v | ||||||
|         _ -> |         _ -> | ||||||
|           case snd $ break (=="--colour") args of |           case dropWhile (/="--colour") args of | ||||||
|             -- --colour ARG |             -- --colour ARG | ||||||
|             "--colour":v:_ -> v |             "--colour":v:_ -> v | ||||||
|             _ -> |             _ -> | ||||||
| @ -250,13 +250,13 @@ hasOutputFile = outputFileOption `notElem` [Nothing, Just "-"] | |||||||
| outputFileOption :: Maybe String | outputFileOption :: Maybe String | ||||||
| outputFileOption =  | outputFileOption =  | ||||||
|   let args = unsafePerformIO getArgs in |   let args = unsafePerformIO getArgs in | ||||||
|   case snd $ break ("-o" `isPrefixOf`) args of |   case dropWhile (not . ("-o" `isPrefixOf`)) args of | ||||||
|     -- -oARG |     -- -oARG | ||||||
|     ('-':'o':v@(_:_)):_ -> Just v |     ('-':'o':v@(_:_)):_ -> Just v | ||||||
|     -- -o ARG |     -- -o ARG | ||||||
|     "-o":v:_ -> Just v |     "-o":v:_ -> Just v | ||||||
|     _ -> |     _ -> | ||||||
|       case snd $ break (=="--output-file") args of |       case dropWhile (/="--output-file") args of | ||||||
|         -- --output-file ARG |         -- --output-file ARG | ||||||
|         "--output-file":v:_ -> Just v |         "--output-file":v:_ -> Just v | ||||||
|         _ -> |         _ -> | ||||||
| @ -288,8 +288,8 @@ ptraceAt level | |||||||
|     | otherwise = \s a -> let p = pshow a |     | otherwise = \s a -> let p = pshow a | ||||||
|                               ls = lines p |                               ls = lines p | ||||||
|                               nlorspace | length ls > 1 = "\n" |                               nlorspace | length ls > 1 = "\n" | ||||||
|                                         | otherwise     = " " ++ take (10 - length s) (repeat ' ') |                                         | otherwise     = replicate (11 - length s) ' ' | ||||||
|                               ls' | length ls > 1 = map (" "++) ls |                               ls' | length ls > 1 = map (' ':) ls | ||||||
|                                   | otherwise     = ls |                                   | otherwise     = ls | ||||||
|                           in trace (s++":"++nlorspace++intercalate "\n" ls') a |                           in trace (s++":"++nlorspace++intercalate "\n" ls') a | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -69,7 +69,7 @@ asInit d reset ui@UIState{ | |||||||
|                    (_, Nothing)            -> 0 |                    (_, Nothing)            -> 0 | ||||||
|                    (_, Just (_,AccountsScreenItem{asItemAccountName=a})) -> |                    (_, Just (_,AccountsScreenItem{asItemAccountName=a})) -> | ||||||
|                      headDef 0 $ catMaybes [ |                      headDef 0 $ catMaybes [ | ||||||
|                        findIndex (a ==) as |                        elemIndex a as | ||||||
|                       ,findIndex (a `isAccountNamePrefixOf`) as |                       ,findIndex (a `isAccountNamePrefixOf`) as | ||||||
|                       ,Just $ max 0 (length (filter (< a) as) - 1) |                       ,Just $ max 0 (length (filter (< a) as) - 1) | ||||||
|                       ] |                       ] | ||||||
|  | |||||||
| @ -397,7 +397,7 @@ balance opts@CliOpts{reportspec_=rspec} j = case balancecalc_ of | |||||||
| -- | Render a single-column balance report as CSV. | -- | Render a single-column balance report as CSV. | ||||||
| balanceReportAsCsv :: ReportOpts -> BalanceReport -> CSV | balanceReportAsCsv :: ReportOpts -> BalanceReport -> CSV | ||||||
| balanceReportAsCsv opts (items, total) = | balanceReportAsCsv opts (items, total) = | ||||||
|   ("account" : ((if commodity_column_ opts then (:) "commodity" else id) $ "balance" : [])) |   ("account" : ((if commodity_column_ opts then (:) "commodity" else id) $ ["balance"])) | ||||||
|   :  (concatMap (\(a, _, _, b) -> rows a b) items) |   :  (concatMap (\(a, _, _, b) -> rows a b) items) | ||||||
|   ++ if no_total_ opts then [] else rows "total" total |   ++ if no_total_ opts then [] else rows "total" total | ||||||
|   where |   where | ||||||
|  | |||||||
| @ -229,7 +229,7 @@ moveFlagsAfterCommand args = moveArgs $ ensureDebugHasArg args | |||||||
|     ensureDebugHasArg as = |     ensureDebugHasArg as = | ||||||
|       case break (=="--debug") as of |       case break (=="--debug") as of | ||||||
|        (bs,"--debug":c:cs) | null c || not (all isDigit c) -> bs++"--debug=1":c:cs |        (bs,"--debug":c:cs) | null c || not (all isDigit c) -> bs++"--debug=1":c:cs | ||||||
|        (bs,"--debug":[])                                   -> bs++"--debug=1":[] |        (bs,["--debug"])                                    -> bs++["--debug=1"] | ||||||
|        _                                                   -> as |        _                                                   -> as | ||||||
| 
 | 
 | ||||||
|     moveArgs args = insertFlagsAfterCommand $ moveArgs' (args, []) |     moveArgs args = insertFlagsAfterCommand $ moveArgs' (args, []) | ||||||
|  | |||||||
| @ -41,14 +41,14 @@ patchlevel = "" | |||||||
| buildversion :: String | buildversion :: String | ||||||
| buildversion = prettify . splitAtElement '.' $ packageversion ++ patchlevel | buildversion = prettify . splitAtElement '.' $ packageversion ++ patchlevel | ||||||
|   where |   where | ||||||
|     prettify (major:minor:bugfix:patches:[]) = |     prettify [major,minor,bugfix,patches] = | ||||||
|         major ++ "." ++ minor ++ bugfix' ++ patches' |         major ++ "." ++ minor ++ bugfix' ++ patches' | ||||||
|       where |       where | ||||||
|         bugfix'  = if bugfix  == "0" then "" else '.' : bugfix |         bugfix'  = if bugfix  == "0" then "" else '.' : bugfix | ||||||
|         patches' = if patches == "0" then "" else '+' : patches |         patches' = if patches == "0" then "" else '+' : patches | ||||||
|     prettify (major:minor:bugfix:[]) = prettify [major,minor,bugfix,"0"] |     prettify [major,minor,bugfix] = prettify [major,minor,bugfix,"0"] | ||||||
|     prettify (major:minor:[])        = prettify [major,minor,"0","0"] |     prettify [major,minor]        = prettify [major,minor,"0","0"] | ||||||
|     prettify (major:[])              = prettify [major,"0","0","0"] |     prettify [major]              = prettify [major,"0","0","0"] | ||||||
|     prettify []                   = error' "VERSION is empty, please fix"  -- PARTIAL: |     prettify []                   = error' "VERSION is empty, please fix"  -- PARTIAL: | ||||||
|     prettify _                    = error' "VERSION has too many components, please fix" |     prettify _                    = error' "VERSION has too many components, please fix" | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -30,4 +30,4 @@ getfields s = name:rest | |||||||
| 
 | 
 | ||||||
| showheading fmt = format fmt ["cost centre","entries","%time","%alloc","%time-inh","%alloc-inh"] | showheading fmt = format fmt ["cost centre","entries","%time","%alloc","%time-inh","%alloc-inh"] | ||||||
| 
 | 
 | ||||||
| format fmt (s1:s2:s3:s4:s5:s6:[]) = printf fmt s1 s2 s3 s4 s5 s6 | format fmt [s1,s2,s3,s4,s5,s6] = printf fmt s1 s2 s3 s4 s5 s6 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user