on master help sign in
Use any instead of or/map and null/filter
688f324Niklas Larsson
src/IRTS/CodegenJavaScript.hs+4−4
@@ -47,7 +47,7 @@ initCompileInfo bc =
47 lookupBigInt = any (needsBigInt . snd)
47 lookupBigInt = any (needsBigInt . snd)
48 where
48 where
49 needsBigInt :: [BC] -> Bool
49 needsBigInt :: [BC] -> Bool
50− needsBigInt bc = or $ map testBCForBigInt bc
50+ needsBigInt bc = any testBCForBigInt bc
51 where
51 where
52 testBCForBigInt :: BC -> Bool
52 testBCForBigInt :: BC -> Bool
53 testBCForBigInt (ASSIGNCONST _ c) =
53 testBCForBigInt (ASSIGNCONST _ c) =
@@ -55,12 +55,12 @@ initCompileInfo bc =
55
55
56 testBCForBigInt (CONSTCASE _ c d) =
56 testBCForBigInt (CONSTCASE _ c d) =
57 maybe False needsBigInt d
57 maybe False needsBigInt d
58− || (or $ map (needsBigInt . snd) c)
58+ || any (needsBigInt . snd) c
59− || (or $ map (testConstForBigInt . fst) c)
59+ || any (testConstForBigInt . fst) c
60
60
61 testBCForBigInt (CASE _ _ c d) =
61 testBCForBigInt (CASE _ _ c d) =
62 maybe False needsBigInt d
62 maybe False needsBigInt d
63− || (or $ map (needsBigInt . snd) c)
63+ || any (needsBigInt . snd) c
64
64
65 testBCForBigInt _ = False
65 testBCForBigInt _ = False
66
66
src/IRTS/Defunctionalise.hs+6−6
@@ -162,21 +162,21 @@ addApps defs (n, LFun _ _ args e)
162 | needsEval x t = DLet x (DV (Glob x)) (preEval xs t)
162 | needsEval x t = DLet x (DV (Glob x)) (preEval xs t)
163 | otherwise = preEval xs t
163 | otherwise = preEval xs t
164
164
165− needsEval x (DApp _ _ args) = or (map (needsEval x) args)
165+ needsEval x (DApp _ _ args) = any (needsEval x) args
166− needsEval x (DC _ _ _ args) = or (map (needsEval x) args)
166+ needsEval x (DC _ _ _ args) = any (needsEval x) args
167− needsEval x (DCase up e alts) = needsEval x e || or (map nec alts)
167+ needsEval x (DCase up e alts) = needsEval x e || any nec alts
168 where nec (DConCase _ _ _ e) = needsEval x e
168 where nec (DConCase _ _ _ e) = needsEval x e
169 nec (DConstCase _ e) = needsEval x e
169 nec (DConstCase _ e) = needsEval x e
170 nec (DDefaultCase e) = needsEval x e
170 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
172 where nec (DConCase _ _ _ e) = needsEval x e
172 where nec (DConCase _ _ _ e) = needsEval x e
173 nec (DConstCase _ e) = needsEval x e
173 nec (DConstCase _ e) = needsEval x e
174 nec (DDefaultCase e) = needsEval x e
174 nec (DDefaultCase e) = needsEval x e
175 needsEval x (DLet n v e)
175 needsEval x (DLet n v e)
176 | x == n = needsEval x v
176 | x == n = needsEval x v
177 | otherwise = needsEval x v || needsEval x e
177 | otherwise = needsEval x v || needsEval x e
178− needsEval x (DForeign _ _ args) = or (map (needsEval x) (map snd args))
178+ needsEval x (DForeign _ _ args) = any (needsEval x) (map snd args)
179− needsEval x (DOp op args) = or (map (needsEval x) args)
179+ needsEval x (DOp op args) = any (needsEval x) args
180 needsEval x (DProj (DV (Glob x')) _) = x == x'
180 needsEval x (DProj (DV (Glob x')) _) = x == x'
181 needsEval x _ = False
181 needsEval x _ = False
182
182
src/Idris/Core/CaseTree.hs+2−2
@@ -209,8 +209,8 @@ findAllUsedArgs sc topargs = filter (\x -> x `elem` topargs) (nu' sc) where
209isUsed :: SC -> Name -> Bool
209isUsed :: SC -> Name -> Bool
210isUsed sc n = used sc where
210isUsed sc n = used sc where
211
211
212− used (Case _ n' alts) = n == n' || or (map usedA alts)
212+ used (Case _ n' alts) = n == n' || any usedA alts
213− used (ProjCase t alts) = n `elem` freeNames t || or (map usedA alts)
213+ used (ProjCase t alts) = n `elem` freeNames t || any usedA alts
214 used (STerm t) = n `elem` freeNames t
214 used (STerm t) = n `elem` freeNames t
215 used _ = False
215 used _ = False
216
216
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
280 = insertDefaults i iname defs ns (insertDef i n dn clauses ns iname ds)
280 = insertDefaults i iname defs ns (insertDef i n dn clauses ns iname ds)
281
281
282 insertDef i meth def clauses ns iname decls
282 insertDef i meth def clauses ns iname decls
283− | null $ filter (clauseFor meth iname ns) decls
283+ | not $ any (clauseFor meth iname ns) decls
284 = let newd = expandParamsD False i (\n -> meth) [] [def] clauses in
284 = let newd = expandParamsD False i (\n -> meth) [] [def] clauses in
285 -- trace (show newd) $
285 -- trace (show newd) $
286 decls ++ [newd]
286 decls ++ [newd]
287 | otherwise = decls
287 | otherwise = decls
288
288
289 warnMissing decls ns iname meth
289 warnMissing decls ns iname meth
290− | null $ filter (clauseFor meth iname ns) decls
290+ | not $ any (clauseFor meth iname ns) decls
291 = iWarn fc . text $ "method " ++ show meth ++ " not defined"
291 = iWarn fc . text $ "method " ++ show meth ++ " not defined"
292 | otherwise = return ()
292 | otherwise = return ()
293
293
294 checkInClass ns meth
294 checkInClass ns meth
295− | not (null (filter (eqRoot meth) ns)) = return ()
295+ | any (eqRoot meth) ns = return ()
296 | otherwise = tclift $ tfail (At fc (Msg $
296 | otherwise = tclift $ tfail (At fc (Msg $
297 show meth ++ " not a method of class " ++ show n))
297 show meth ++ " not a method of class " ++ show n))
298
298
src/Idris/Error.hs+1−1
@@ -136,7 +136,7 @@ warnDisamb ist (PCoerced tm) = warnDisamb ist tm
136warnDisamb ist (PDisamb ds tm) = warnDisamb ist tm >>
136warnDisamb ist (PDisamb ds tm) = warnDisamb ist tm >>
137 mapM_ warnEmpty ds
137 mapM_ warnEmpty ds
138 where warnEmpty d =
138 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)))) $
140 ierror . Msg $
140 ierror . Msg $
141 "Nothing found in namespace \"" ++
141 "Nothing found in namespace \"" ++
142 intercalate "." (map T.unpack d) ++
142 intercalate "." (map T.unpack d) ++