on master help sign in
Use any instead of or/map and null/filter

From suggestions by hlint.

commit688f3248038a7ab0021ab615419ce6c2aff2aefb authorNiklas Larsson <niklas@mm.st> dateThu 30 Apr 2015, 14:05 (11 years ago) parenta244cd5
5 files changed+16−16
src/IRTS/CodegenJavaScript.hs+4−4 src/IRTS/Defunctionalise.hs+6−6 src/Idris/Core/CaseTree.hs+2−2 src/Idris/Elab/Instance.hs+3−3 src/Idris/Error.hs+1−1
src/IRTS/CodegenJavaScript.hs+4−4
@@ -47,7 +47,7 @@ initCompileInfo bc =
4747 lookupBigInt = any (needsBigInt . snd)
4848 where
4949 needsBigInt :: [BC] -> Bool
50− needsBigInt bc = or $ map testBCForBigInt bc
50+ needsBigInt bc = any testBCForBigInt bc
5151 where
5252 testBCForBigInt :: BC -> Bool
5353 testBCForBigInt (ASSIGNCONST _ c) =
@@ -55,12 +55,12 @@ initCompileInfo bc =
5555
5656 testBCForBigInt (CONSTCASE _ c d) =
5757 maybe False needsBigInt d
58− || (or $ map (needsBigInt . snd) c)
59− || (or $ map (testConstForBigInt . fst) c)
58+ || any (needsBigInt . snd) c
59+ || any (testConstForBigInt . fst) c
6060
6161 testBCForBigInt (CASE _ _ c d) =
6262 maybe False needsBigInt d
63− || (or $ map (needsBigInt . snd) c)
63+ || any (needsBigInt . snd) c
6464
6565 testBCForBigInt _ = False
6666
src/IRTS/Defunctionalise.hs+6−6
@@ -162,21 +162,21 @@ addApps defs (n, LFun _ _ args e)
162162 | needsEval x t = DLet x (DV (Glob x)) (preEval xs t)
163163 | otherwise = preEval xs t
164164
165− needsEval x (DApp _ _ args) = or (map (needsEval x) args)
166− needsEval x (DC _ _ _ args) = or (map (needsEval x) args)
167− needsEval x (DCase up e alts) = needsEval x e || or (map nec alts)
165+ needsEval x (DApp _ _ args) = any (needsEval x) args
166+ needsEval x (DC _ _ _ args) = any (needsEval x) args
167+ needsEval x (DCase up e alts) = needsEval x e || any nec alts
168168 where nec (DConCase _ _ _ e) = needsEval x e
169169 nec (DConstCase _ e) = needsEval x e
170170 nec (DDefaultCase e) = needsEval x e
171− needsEval x (DChkCase e alts) = needsEval x e || or (map nec alts)
171+ needsEval x (DChkCase e alts) = needsEval x e || any nec alts
172172 where nec (DConCase _ _ _ e) = needsEval x e
173173 nec (DConstCase _ e) = needsEval x e
174174 nec (DDefaultCase e) = needsEval x e
175175 needsEval x (DLet n v e)
176176 | x == n = needsEval x v
177177 | otherwise = needsEval x v || needsEval x e
178− needsEval x (DForeign _ _ args) = or (map (needsEval x) (map snd args))
179− needsEval x (DOp op args) = or (map (needsEval x) args)
178+ needsEval x (DForeign _ _ args) = any (needsEval x) (map snd args)
179+ needsEval x (DOp op args) = any (needsEval x) args
180180 needsEval x (DProj (DV (Glob x')) _) = x == x'
181181 needsEval x _ = False
182182
src/Idris/Core/CaseTree.hs+2−2
@@ -209,8 +209,8 @@ findAllUsedArgs sc topargs = filter (\x -> x `elem` topargs) (nu' sc) where
209209isUsed :: SC -> Name -> Bool
210210isUsed sc n = used sc where
211211
212− used (Case _ n' alts) = n == n' || or (map usedA alts)
213− used (ProjCase t alts) = n `elem` freeNames t || or (map usedA alts)
212+ used (Case _ n' alts) = n == n' || any usedA alts
213+ used (ProjCase t alts) = n `elem` freeNames t || any usedA alts
214214 used (STerm t) = n `elem` freeNames t
215215 used _ = False
216216
src/Idris/Elab/Instance.hs+3−3
@@ -280,19 +280,19 @@ elabInstance info syn doc argDocs what fc cs n ps t expn ds = do
280280 = insertDefaults i iname defs ns (insertDef i n dn clauses ns iname ds)
281281
282282 insertDef i meth def clauses ns iname decls
283− | null $ filter (clauseFor meth iname ns) decls
283+ | not $ any (clauseFor meth iname ns) decls
284284 = let newd = expandParamsD False i (\n -> meth) [] [def] clauses in
285285 -- trace (show newd) $
286286 decls ++ [newd]
287287 | otherwise = decls
288288
289289 warnMissing decls ns iname meth
290− | null $ filter (clauseFor meth iname ns) decls
290+ | not $ any (clauseFor meth iname ns) decls
291291 = iWarn fc . text $ "method " ++ show meth ++ " not defined"
292292 | otherwise = return ()
293293
294294 checkInClass ns meth
295− | not (null (filter (eqRoot meth) ns)) = return ()
295+ | any (eqRoot meth) ns = return ()
296296 | otherwise = tclift $ tfail (At fc (Msg $
297297 show meth ++ " not a method of class " ++ show n))
298298
src/Idris/Error.hs+1−1
@@ -136,7 +136,7 @@ warnDisamb ist (PCoerced tm) = warnDisamb ist tm
136136warnDisamb ist (PDisamb ds tm) = warnDisamb ist tm >>
137137 mapM_ warnEmpty ds
138138 where warnEmpty d =
139− when (null (filter (isIn d . fst) (ctxtAlist (tt_ctxt ist)))) $
139+ when (not (any (isIn d . fst) (ctxtAlist (tt_ctxt ist)))) $
140140 ierror . Msg $
141141 "Nothing found in namespace \"" ++
142142 intercalate "." (map T.unpack d) ++