summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2016-05-10 09:57:02 (GMT)
committerBen Gamari <ben@smart-cactus.org>2016-05-12 13:16:07 (GMT)
commitba46dd060f959e3c96a74c1546946c3f8bf84dd0 (patch)
treefaa22032f485d0222bb102645971dd82e76236c2
parente996e85f003e783fc8f9af0da653cdd0058d9646 (diff)
downloadghc-wip/foldl.zip
ghc-wip/foldl.tar.gz
ghc-wip/foldl.tar.bz2
Use strict foldlswip/foldl
-rw-r--r--compiler/basicTypes/NameSet.hs3
-rw-r--r--compiler/basicTypes/OccName.hs3
-rw-r--r--compiler/basicTypes/RdrName.hs4
-rw-r--r--compiler/basicTypes/VarEnv.hs5
-rw-r--r--compiler/cmm/CmmBuildInfoTables.hs8
-rw-r--r--compiler/cmm/CmmCommonBlockElim.hs2
-rw-r--r--compiler/cmm/CmmLayoutStack.hs4
-rw-r--r--compiler/cmm/CmmProcPoint.hs16
-rw-r--r--compiler/cmm/CmmSink.hs6
-rw-r--r--compiler/codeGen/StgCmmEnv.hs8
-rw-r--r--compiler/codeGen/StgCmmMonad.hs2
-rw-r--r--compiler/codeGen/StgCmmPrim.hs2
-rw-r--r--compiler/coreSyn/CoreArity.hs3
-rw-r--r--compiler/coreSyn/CoreSubst.hs11
-rw-r--r--compiler/coreSyn/CoreSyn.hs9
-rw-r--r--compiler/coreSyn/CoreUtils.hs4
-rw-r--r--compiler/coreSyn/TrieMap.hs5
-rw-r--r--compiler/deSugar/DsExpr.hs3
-rw-r--r--compiler/deSugar/DsForeign.hs2
-rw-r--r--compiler/deSugar/DsMeta.hs2
-rw-r--r--compiler/deSugar/DsUtils.hs3
-rw-r--r--compiler/deSugar/Match.hs3
-rw-r--r--compiler/hsSyn/HsTypes.hs3
-rw-r--r--compiler/hsSyn/HsUtils.hs14
-rw-r--r--compiler/iface/IfaceEnv.hs4
-rw-r--r--compiler/main/GhcMake.hs6
-rw-r--r--compiler/main/HscMain.hs4
-rw-r--r--compiler/main/HscTypes.hs3
-rw-r--r--compiler/main/Packages.hs2
-rw-r--r--compiler/nativeGen/AsmCodeGen.hs9
-rw-r--r--compiler/rename/RnNames.hs6
-rw-r--r--compiler/simplCore/CallArity.hs3
-rw-r--r--compiler/simplCore/FloatIn.hs6
-rw-r--r--compiler/simplCore/SetLevels.hs18
-rw-r--r--compiler/specialise/Rules.hs4
-rw-r--r--compiler/specialise/Specialise.hs3
-rw-r--r--compiler/stranal/DmdAnal.hs4
-rw-r--r--compiler/typecheck/FunDeps.hs4
-rw-r--r--compiler/typecheck/TcBinds.hs3
-rw-r--r--compiler/typecheck/TcExpr.hs6
-rw-r--r--compiler/typecheck/TcGenDeriv.hs12
-rw-r--r--compiler/typecheck/TcInstDcls.hs3
-rw-r--r--compiler/typecheck/TcPatSyn.hs8
-rw-r--r--compiler/typecheck/TcRnTypes.hs3
-rw-r--r--compiler/typecheck/TcSplice.hs3
-rw-r--r--compiler/typecheck/TcType.hs3
-rw-r--r--compiler/typecheck/TcValidity.hs10
-rw-r--r--compiler/types/Coercion.hs11
-rw-r--r--compiler/types/FamInstEnv.hs3
-rw-r--r--compiler/types/InstEnv.hs3
-rw-r--r--compiler/types/TyCoRep.hs2
-rw-r--r--compiler/types/Type.hs3
-rw-r--r--compiler/utils/Bag.hs4
-rw-r--r--compiler/utils/FiniteMap.hs7
-rw-r--r--compiler/utils/OrdList.hs3
-rw-r--r--compiler/utils/UniqDFM.hs8
-rw-r--r--compiler/utils/UniqDSet.hs5
-rw-r--r--compiler/utils/UniqFM.hs17
-rw-r--r--compiler/utils/UniqSet.hs5
-rw-r--r--compiler/utils/Util.hs2
60 files changed, 178 insertions, 147 deletions
diff --git a/compiler/basicTypes/NameSet.hs b/compiler/basicTypes/NameSet.hs
index b332fe2..4168e5a 100644
--- a/compiler/basicTypes/NameSet.hs
+++ b/compiler/basicTypes/NameSet.hs
@@ -33,6 +33,7 @@ module NameSet (
#include "HsVersions.h"
+import Data.Foldable (foldl')
import Name
import UniqSet
@@ -82,7 +83,7 @@ foldNameSet = foldUniqSet
filterNameSet = filterUniqSet
intersectNameSet = intersectUniqSets
-delListFromNameSet set ns = foldl delFromNameSet set ns
+delListFromNameSet set ns = foldl' delFromNameSet set ns
intersectsNameSet s1 s2 = not (isEmptyNameSet (s1 `intersectNameSet` s2))
diff --git a/compiler/basicTypes/OccName.hs b/compiler/basicTypes/OccName.hs
index e15cfbb..1e3017d 100644
--- a/compiler/basicTypes/OccName.hs
+++ b/compiler/basicTypes/OccName.hs
@@ -115,6 +115,7 @@ import Binary
import Module
import Data.Char
import Data.Data
+import Data.Foldable (foldl')
{-
************************************************************************
@@ -831,7 +832,7 @@ emptyTidyOccEnv :: TidyOccEnv
emptyTidyOccEnv = emptyUFM
initTidyOccEnv :: [OccName] -> TidyOccEnv -- Initialise with names to avoid!
-initTidyOccEnv = foldl add emptyUFM
+initTidyOccEnv = foldl' add emptyUFM
where
add env (OccName _ fs) = addToUFM env fs 1
diff --git a/compiler/basicTypes/RdrName.hs b/compiler/basicTypes/RdrName.hs
index ee63882..f10bd8c 100644
--- a/compiler/basicTypes/RdrName.hs
+++ b/compiler/basicTypes/RdrName.hs
@@ -78,7 +78,7 @@ import Util
import StaticFlags( opt_PprStyle_Debug )
import Data.Data
-import Data.List( sortBy )
+import Data.List( sortBy, foldl' )
{-
************************************************************************
@@ -913,7 +913,7 @@ extendGlobalRdrEnv env gre
(greOccName gre) gre
shadowNames :: GlobalRdrEnv -> [Name] -> GlobalRdrEnv
-shadowNames = foldl shadowName
+shadowNames = foldl' shadowName
{- Note [GlobalRdrEnv shadowing]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/compiler/basicTypes/VarEnv.hs b/compiler/basicTypes/VarEnv.hs
index 917946f..b57b22e 100644
--- a/compiler/basicTypes/VarEnv.hs
+++ b/compiler/basicTypes/VarEnv.hs
@@ -62,6 +62,7 @@ module VarEnv (
emptyTidyEnv
) where
+import Data.Foldable (foldl')
import OccName
import Var
import VarSet
@@ -120,8 +121,8 @@ extendInScopeSet (InScope in_scope n) v = InScope (extendVarEnv in_scope v v) (n
extendInScopeSetList :: InScopeSet -> [Var] -> InScopeSet
extendInScopeSetList (InScope in_scope n) vs
- = InScope (foldl (\s v -> extendVarEnv s v v) in_scope vs)
- (n + length vs)
+ = InScope (foldl' (\s v -> extendVarEnv s v v) in_scope vs)
+ (n + length vs)
extendInScopeSetSet :: InScopeSet -> VarEnv Var -> InScopeSet
extendInScopeSetSet (InScope in_scope n) vs
diff --git a/compiler/cmm/CmmBuildInfoTables.hs b/compiler/cmm/CmmBuildInfoTables.hs
index dafaea3..9adbe26 100644
--- a/compiler/cmm/CmmBuildInfoTables.hs
+++ b/compiler/cmm/CmmBuildInfoTables.hs
@@ -171,7 +171,7 @@ buildSRT dflags topSRT cafs =
do localSRTs <- procpointSRT dflags (lbl topSRT) (elt_map topSRT) cafs
return (topSRT, localSRTs)
in if length cafs > maxBmpSize dflags then
- mkSRT (foldl add_if_missing topSRT cafs)
+ mkSRT (foldl' add_if_missing topSRT cafs)
else -- make sure all the cafs are near the bottom of the srt
mkSRT (add_if_too_far topSRT cafs)
add_if_missing srt caf =
@@ -264,14 +264,14 @@ localCAFInfo cafEnv proc@(CmmProc _ top_l _ (CmmGraph {g_entry=entry})) =
-- To do this replacement efficiently, we gather strongly connected
-- components, then we sort the components in topological order.
mkTopCAFInfo :: [(CAFSet, Maybe CLabel)] -> Map CLabel CAFSet
-mkTopCAFInfo localCAFs = foldl addToTop Map.empty g
+mkTopCAFInfo localCAFs = foldl' addToTop Map.empty g
where
addToTop env (AcyclicSCC (l, cafset)) =
Map.insert l (flatten env cafset) env
addToTop env (CyclicSCC nodes) =
let (lbls, cafsets) = unzip nodes
- cafset = foldr Set.delete (foldl Set.union Set.empty cafsets) lbls
- in foldl (\env l -> Map.insert l (flatten env cafset) env) env lbls
+ cafset = foldr Set.delete (Set.unions cafsets) lbls
+ in foldl' (\env l -> Map.insert l (flatten env cafset) env) env lbls
g = stronglyConnCompFromEdgedVertices
[ ((l,cafs), l, Set.elems cafs) | (cafs, Just l) <- localCAFs ]
diff --git a/compiler/cmm/CmmCommonBlockElim.hs b/compiler/cmm/CmmCommonBlockElim.hs
index 6c4742e..fdba55c 100644
--- a/compiler/cmm/CmmCommonBlockElim.hs
+++ b/compiler/cmm/CmmCommonBlockElim.hs
@@ -168,7 +168,7 @@ hash_block block =
hash_tgt (ForeignTarget e _) = hash_e e
hash_tgt (PrimTarget _) = 31 -- lots of these
- hash_list f = foldl (\z x -> f x + z) (0::Word32)
+ hash_list f = sum . map f
cvt = fromInteger . toInteger
diff --git a/compiler/cmm/CmmLayoutStack.hs b/compiler/cmm/CmmLayoutStack.hs
index 25a0ad6..6e0fd69 100644
--- a/compiler/cmm/CmmLayoutStack.hs
+++ b/compiler/cmm/CmmLayoutStack.hs
@@ -31,7 +31,7 @@ import qualified Data.Set as Set
import Control.Monad.Fix
import Data.Array as Array
import Data.Bits
-import Data.List (nub)
+import Data.List (nub, foldl')
import Control.Monad (liftM)
import Prelude hiding ((<*>))
@@ -274,7 +274,7 @@ layout dflags procpoints liveness entry entry_args final_stackmaps final_sp_high
-- Sp = Sp + sp_off -- Sp adjustment goes here
-- last1 -- the last node
--
- let middle_pre = blockToList $ foldl blockSnoc middle1 middle2
+ let middle_pre = blockToList $ foldl' blockSnoc middle1 middle2
final_blocks = manifestSp dflags final_stackmaps stack0 sp0 final_sp_high entry0
middle_pre sp_off last1 fixup_blocks
diff --git a/compiler/cmm/CmmProcPoint.hs b/compiler/cmm/CmmProcPoint.hs
index 0e772c4..3518249 100644
--- a/compiler/cmm/CmmProcPoint.hs
+++ b/compiler/cmm/CmmProcPoint.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE GADTs, DisambiguateRecordFields #-}
+{-# LANGUAGE GADTs, DisambiguateRecordFields, BangPatterns #-}
module CmmProcPoint
( ProcPointSet, Status(..)
@@ -19,7 +19,7 @@ import CmmUtils
import CmmInfo
import CmmLive (cmmGlobalLiveness)
import CmmSwitch
-import Data.List (sortBy)
+import Data.List (sortBy, foldl')
import Maybes
import Control.Monad
import Outputable
@@ -215,7 +215,7 @@ extendPPSet platform g blocks procPoints =
case newPoints of
[] -> return procPoints'
pps -> extendPPSet g blocks
- (foldl extendBlockSet procPoints' pps)
+ (foldl' extendBlockSet procPoints' pps)
-}
case newPoint of
Just id ->
@@ -276,8 +276,8 @@ splitAtProcPoints dflags entry_label callPPs procPoints procMap
where block_lbl = blockLbl pp
procLabels :: LabelMap (CLabel, Maybe CLabel)
- procLabels = foldl add_label mapEmpty
- (filter (flip mapMember (toBlockMap g)) (setElems procPoints))
+ procLabels = foldl' add_label mapEmpty
+ (filter (flip mapMember (toBlockMap g)) (setElems procPoints))
-- In each new graph, add blocks jumping off to the new procedures,
-- and replace branches to procpoints with branches to the jump-off blocks
@@ -318,7 +318,7 @@ splitAtProcPoints dflags entry_label callPPs procPoints procMap
-- replace branches to procpoints with branches to jumps
blockEnv'' = toBlockMap $ replaceBranches jumpEnv $ ofBlockMap ppId blockEnv'
-- add the jump blocks to the graph
- blockEnv''' = foldl (flip insertBlock) blockEnv'' jumpBlocks
+ blockEnv''' = foldl' (flip insertBlock) blockEnv'' jumpBlocks
let g' = ofBlockMap ppId blockEnv'''
-- pprTrace "g' pre jumps" (ppr g') $ do
return (mapInsert ppId g' newGraphEnv)
@@ -360,8 +360,8 @@ splitAtProcPoints dflags entry_label callPPs procPoints procMap
-- The C back end expects to see return continuations before the
-- call sites. Here, we sort them in reverse order -- it gets
-- reversed later.
- let (_, block_order) = foldl add_block_num (0::Int, emptyBlockMap) (postorderDfs g)
- add_block_num (i, map) block = (i+1, mapInsert (entryLabel block) i map)
+ let (_, block_order) = foldl' add_block_num (0::Int, emptyBlockMap) (postorderDfs g)
+ add_block_num (!i, !map) block = (i+1, mapInsert (entryLabel block) i map)
sort_fn (bid, _) (bid', _) =
compare (expectJust "block_order" $ mapLookup bid block_order)
(expectJust "block_order" $ mapLookup bid' block_order)
diff --git a/compiler/cmm/CmmSink.hs b/compiler/cmm/CmmSink.hs
index 7279013..17f31f9 100644
--- a/compiler/cmm/CmmSink.hs
+++ b/compiler/cmm/CmmSink.hs
@@ -16,7 +16,7 @@ import DynFlags
import UniqFM
import PprCmm ()
-import Data.List (partition)
+import Data.List (partition, foldl')
import qualified Data.Set as Set
import Data.Maybe
@@ -211,7 +211,7 @@ cmmSink dflags graph = ofBlockList (g_entry graph) $ sink mapEmpty $ blocks
live_rhs = foldRegsUsed dflags extendRegSet emptyRegSet rhs
- final_middle = foldl blockSnoc middle' dropped_last
+ final_middle = foldl' blockSnoc middle' dropped_last
sunk' = mapUnion sunk $
mapFromList [ (l, filterAssignments dflags (getLive l) assigs'')
@@ -321,7 +321,7 @@ walk dflags nodes assigs = go nodes emptyBlock assigs
(dropped, as') = dropAssignmentsSimple dflags
(\a -> conflicts dflags a node2) as1
- block' = foldl blockSnoc block dropped `blockSnoc` node2
+ block' = foldl' blockSnoc block dropped `blockSnoc` node2
--
diff --git a/compiler/codeGen/StgCmmEnv.hs b/compiler/codeGen/StgCmmEnv.hs
index 8dbb646..a6dc5cb 100644
--- a/compiler/codeGen/StgCmmEnv.hs
+++ b/compiler/codeGen/StgCmmEnv.hs
@@ -45,6 +45,8 @@ import Name
import StgSyn
import Outputable
+import Data.Foldable ( foldl' )
+
-------------------------------------
-- Non-void types
-------------------------------------
@@ -130,9 +132,9 @@ addBindC stuff_to_bind = do
addBindsC :: [CgIdInfo] -> FCode ()
addBindsC new_bindings = do
binds <- getBinds
- let new_binds = foldl (\ binds info -> extendVarEnv binds (cg_id info) info)
- binds
- new_bindings
+ let new_binds = foldl' (\ binds info -> extendVarEnv binds (cg_id info) info)
+ binds
+ new_bindings
setBinds new_binds
getCgIdInfo :: Id -> FCode CgIdInfo
diff --git a/compiler/codeGen/StgCmmMonad.hs b/compiler/codeGen/StgCmmMonad.hs
index 2742acd..2bac864 100644
--- a/compiler/codeGen/StgCmmMonad.hs
+++ b/compiler/codeGen/StgCmmMonad.hs
@@ -662,7 +662,7 @@ forkAlts branch_fcodes
, cgs_hp_usg = cgs_hp_usg state }
(_us, results) = mapAccumL compile us branch_fcodes
(branch_results, branch_out_states) = unzip results
- ; setState $ foldl stateIncUsage state branch_out_states
+ ; setState $ foldl' stateIncUsage state branch_out_states
-- NB foldl. state is the *left* argument to stateIncUsage
; return branch_results }
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs
index 84f263c..138041b 100644
--- a/compiler/codeGen/StgCmmPrim.hs
+++ b/compiler/codeGen/StgCmmPrim.hs
@@ -1030,7 +1030,7 @@ genericWordMul2Op [res_h, res_l] [arg_x, arg_y]
toTopHalf x = CmmMachOp (MO_Shl (wordWidth dflags)) [x, hww]
bottomHalf x = CmmMachOp (MO_And (wordWidth dflags)) [x, hwm]
add x y = CmmMachOp (MO_Add (wordWidth dflags)) [x, y]
- sum = foldl1 add
+ sum = foldl1' add
mul x y = CmmMachOp (MO_Mul (wordWidth dflags)) [x, y]
or x y = CmmMachOp (MO_Or (wordWidth dflags)) [x, y]
hww = CmmLit (CmmInt (fromIntegral (widthInBits (halfWordWidth dflags)))
diff --git a/compiler/coreSyn/CoreArity.hs b/compiler/coreSyn/CoreArity.hs
index 59c261b..ed46c89 100644
--- a/compiler/coreSyn/CoreArity.hs
+++ b/compiler/coreSyn/CoreArity.hs
@@ -34,6 +34,7 @@ import Outputable
import FastString
import Pair
import Util ( debugIsOn )
+import Data.Foldable ( foldl' )
{-
************************************************************************
@@ -884,7 +885,7 @@ etaExpand n orig_expr
-- See Note [Eta expansion and source notes]
(expr', args) = collectArgs expr
(ticks, expr'') = stripTicksTop tickishFloatable expr'
- sexpr = foldl App expr'' args
+ sexpr = foldl' App expr'' args
retick expr = foldr mkTick expr ticks
-- Wrapper Unwrapper
diff --git a/compiler/coreSyn/CoreSubst.hs b/compiler/coreSyn/CoreSubst.hs
index 1f60e7c..8bc9cb6 100644
--- a/compiler/coreSyn/CoreSubst.hs
+++ b/compiler/coreSyn/CoreSubst.hs
@@ -7,6 +7,7 @@ Utility functions on @Core@ syntax
-}
{-# LANGUAGE CPP #-}
+{-# LANGUAGE BangPatterns #-}
module CoreSubst (
-- * Main data types
Subst(..), -- Implementation exported for supercompiler's Renaming.hs only
@@ -898,9 +899,9 @@ simpleOptPgm dflags this_mod binds rules vects
where
occ_anald_binds = occurAnalysePgm this_mod (\_ -> False) {- No rules active -}
rules vects emptyVarEnv binds
- (subst', binds') = foldl do_one (emptySubst, []) occ_anald_binds
+ (subst', binds') = foldl' do_one (emptySubst, []) occ_anald_binds
- do_one (subst, binds') bind
+ do_one (!subst, !binds') bind
= case simple_opt_bind subst bind of
(subst', Nothing) -> (subst', binds')
(subst', Just bind') -> (subst', bind':binds')
@@ -1006,7 +1007,7 @@ simple_app subst (Tick t e) as
| t `tickishScopesLike` SoftScope
= mkTick t $ simple_app subst e as
simple_app subst e as
- = foldl App (simple_opt_expr subst e) as
+ = foldl' App (simple_opt_expr subst e) as
----------------------
simple_opt_bind,simple_opt_bind' :: Subst -> CoreBind -> (Subst, Maybe CoreBind)
@@ -1018,8 +1019,8 @@ simple_opt_bind' subst (Rec prs)
where
res_bind = Just (Rec (reverse rev_prs'))
(subst', bndrs') = subst_opt_bndrs subst (map fst prs)
- (subst'', rev_prs') = foldl do_pr (subst', []) (prs `zip` bndrs')
- do_pr (subst, prs) ((b,r), b')
+ (subst'', rev_prs') = foldl' do_pr (subst', []) (prs `zip` bndrs')
+ do_pr (!subst, !prs) ((b,r), b')
= case maybe_substitute subst b r2 of
Just subst' -> (subst', prs)
Nothing -> (subst, (b2,r2):prs)
diff --git a/compiler/coreSyn/CoreSyn.hs b/compiler/coreSyn/CoreSyn.hs
index 432f242..c777f62 100644
--- a/compiler/coreSyn/CoreSyn.hs
+++ b/compiler/coreSyn/CoreSyn.hs
@@ -108,6 +108,7 @@ import SrcLoc ( RealSrcSpan, containsSpan )
import Binary
import Data.Data hiding (TyCon)
+import Data.Foldable ( foldl' )
import Data.Int
import Data.Word
@@ -1457,12 +1458,12 @@ mkVarApps :: Expr b -> [Var] -> Expr b
-- use 'MkCore.mkCoreConApps' if possible
mkConApp :: DataCon -> [Arg b] -> Expr b
-mkApps f args = foldl App f args
-mkCoApps f args = foldl (\ e a -> App e (Coercion a)) f args
-mkVarApps f vars = foldl (\ e a -> App e (varToCoreExpr a)) f vars
+mkApps f args = foldl' App f args
+mkCoApps f args = foldl' (\ e a -> App e (Coercion a)) f args
+mkVarApps f vars = foldl' (\ e a -> App e (varToCoreExpr a)) f vars
mkConApp con args = mkApps (Var (dataConWorkId con)) args
-mkTyApps f args = foldl (\ e a -> App e (typeOrCoercion a)) f args
+mkTyApps f args = foldl' (\ e a -> App e (typeOrCoercion a)) f args
where
typeOrCoercion ty
| Just co <- isCoercionTy_maybe ty = Coercion co
diff --git a/compiler/coreSyn/CoreUtils.hs b/compiler/coreSyn/CoreUtils.hs
index 887c313..cc1d4c7 100644
--- a/compiler/coreSyn/CoreUtils.hs
+++ b/compiler/coreSyn/CoreUtils.hs
@@ -964,8 +964,8 @@ exprIsWorkFree e = go 0 e
go _ (Type {}) = True
go _ (Coercion {}) = True
go n (Cast e _) = go n e
- go n (Case scrut _ _ alts) = foldl (&&) (exprIsWorkFree scrut)
- [ go n rhs | (_,_,rhs) <- alts ]
+ go n (Case scrut _ _ alts) = exprIsWorkFree scrut
+ && and [ go n rhs | (_,_,rhs) <- alts ]
-- See Note [Case expressions are work-free]
go _ (Let {}) = False
go n (Var v) = isCheapApp v n
diff --git a/compiler/coreSyn/TrieMap.hs b/compiler/coreSyn/TrieMap.hs
index fbff260..afee992 100644
--- a/compiler/coreSyn/TrieMap.hs
+++ b/compiler/coreSyn/TrieMap.hs
@@ -29,6 +29,7 @@ import UniqDFM
import Unique( Unique )
import FastString(FastString)
+import Data.Foldable ( foldl' )
import qualified Data.Map as Map
import qualified Data.IntMap as IntMap
import VarEnv
@@ -792,7 +793,7 @@ data TypeMapX a
-- to nested AppTys. Why the last one? See Note [Equality on AppTys] in Type
trieMapView :: Type -> Maybe Type
trieMapView ty | Just ty' <- coreViewOneStarKind ty = Just ty'
-trieMapView (TyConApp tc tys@(_:_)) = Just $ foldl AppTy (TyConApp tc []) tys
+trieMapView (TyConApp tc tys@(_:_)) = Just $ foldl' AppTy (TyConApp tc []) tys
trieMapView (ForAllTy (Anon arg) res)
= Just ((TyConApp funTyCon [] `AppTy` arg) `AppTy` res)
trieMapView _ = Nothing
@@ -1008,7 +1009,7 @@ extendCME (CME { cme_next = bv, cme_env = env }) v
= CME { cme_next = bv+1, cme_env = extendVarEnv env v bv }
extendCMEs :: CmEnv -> [Var] -> CmEnv
-extendCMEs env vs = foldl extendCME env vs
+extendCMEs env vs = foldl' extendCME env vs
lookupCME :: CmEnv -> Var -> Maybe BoundVar
lookupCME (CME { cme_env = env }) v = lookupVarEnv env v
diff --git a/compiler/deSugar/DsExpr.hs b/compiler/deSugar/DsExpr.hs
index c33b867..2d7533f 100644
--- a/compiler/deSugar/DsExpr.hs
+++ b/compiler/deSugar/DsExpr.hs
@@ -57,6 +57,7 @@ import Outputable
import FastString
import PatSyn
+import Data.Foldable ( foldl' )
import Data.IORef ( atomicModifyIORef' )
import Control.Monad
@@ -648,7 +649,7 @@ dsExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = fields
mkWpTyApps [ ty
| (tv, ty) <- univ_tvs `zip` out_inst_tys
, not (tv `elemVarEnv` wrap_subst) ]
- rhs = foldl (\a b -> nlHsApp a b) inst_con val_args
+ rhs = foldl' (\a b -> nlHsApp a b) inst_con val_args
-- Tediously wrap the application in a cast
-- Note [Update for GADTs]
diff --git a/compiler/deSugar/DsForeign.hs b/compiler/deSugar/DsForeign.hs
index 26c84c7..10d0cb2 100644
--- a/compiler/deSugar/DsForeign.hs
+++ b/compiler/deSugar/DsForeign.hs
@@ -610,7 +610,7 @@ mkFExportCBits dflags c_nm maybe_target arg_htys res_hty is_IO_res_ty cc
-- the expression we give to rts_evalIO
expr_to_run
- = foldl appArg the_cfun arg_info -- NOT aug_arg_info
+ = foldl' appArg the_cfun arg_info -- NOT aug_arg_info
where
appArg acc (arg_cname, _, arg_hty, _)
= text "rts_apply"
diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs
index b00717e..2a8ccff 100644
--- a/compiler/deSugar/DsMeta.hs
+++ b/compiler/deSugar/DsMeta.hs
@@ -1658,7 +1658,7 @@ unC (MkC x) = x
rep2 :: Name -> [ CoreExpr ] -> DsM (Core a)
rep2 n xs = do { id <- dsLookupGlobalId n
- ; return (MkC (foldl App (Var id) xs)) }
+ ; return (MkC (foldl' App (Var id) xs)) }
dataCon' :: Name -> [CoreExpr] -> DsM (Core a)
dataCon' n args = do { id <- dsLookupDataCon n
diff --git a/compiler/deSugar/DsUtils.hs b/compiler/deSugar/DsUtils.hs
index 2e76c93..0ec2623 100644
--- a/compiler/deSugar/DsUtils.hs
+++ b/compiler/deSugar/DsUtils.hs
@@ -77,6 +77,7 @@ import qualified GHC.LanguageExtensions as LangExt
import TcEvidence
+import Data.Foldable ( foldl' )
import Control.Monad ( zipWithM )
{-
@@ -552,7 +553,7 @@ mkCoreAppDs _ (Var f `App` Type ty1 `App` Type ty2 `App` arg1) arg2
mkCoreAppDs s fun arg = mkCoreApp s fun arg -- The rest is done in MkCore
mkCoreAppsDs :: SDoc -> CoreExpr -> [CoreExpr] -> CoreExpr
-mkCoreAppsDs s fun args = foldl (mkCoreAppDs s) fun args
+mkCoreAppsDs s fun args = foldl' (mkCoreAppDs s) fun args
mkCastDs :: CoreExpr -> Coercion -> CoreExpr
-- We define a desugarer-specific version of CoreUtils.mkCast,
diff --git a/compiler/deSugar/Match.hs b/compiler/deSugar/Match.hs
index fc70cc6..cf50cac 100644
--- a/compiler/deSugar/Match.hs
+++ b/compiler/deSugar/Match.hs
@@ -47,6 +47,7 @@ import Name
import Outputable
import BasicTypes ( isGenerated )
+import Data.Foldable ( foldl' )
import Control.Monad( when, unless )
import qualified Data.Map as Map
@@ -815,7 +816,7 @@ subGroup :: Ord a => [(a, EquationInfo)] -> [[EquationInfo]]
-- Each sub-list in the result has the same PatGroup
-- See Note [Take care with pattern order]
subGroup group
- = map reverse $ Map.elems $ foldl accumulate Map.empty group
+ = map reverse $ Map.elems $ foldl' accumulate Map.empty group
where
accumulate pg_map (pg, eqn)
= case Map.lookup pg pg_map of
diff --git a/compiler/hsSyn/HsTypes.hs b/compiler/hsSyn/HsTypes.hs
index 04b0ae8..168553c 100644
--- a/compiler/hsSyn/HsTypes.hs
+++ b/compiler/hsSyn/HsTypes.hs
@@ -89,6 +89,7 @@ import Maybes( isJust )
import Data.Data hiding ( Fixity )
import Data.Maybe ( fromMaybe )
+import Data.Foldable ( foldl' )
import Control.Monad ( unless )
#if __GLASGOW_HASKELL > 710
import Data.Semigroup ( Semigroup )
@@ -894,7 +895,7 @@ mkHsAppTy :: LHsType name -> LHsType name -> LHsType name
mkHsAppTy t1 t2 = addCLoc t1 t2 (HsAppTy t1 t2)
mkHsAppTys :: LHsType name -> [LHsType name] -> LHsType name
-mkHsAppTys = foldl mkHsAppTy
+mkHsAppTys = foldl' mkHsAppTy
{-
diff --git a/compiler/hsSyn/HsUtils.hs b/compiler/hsSyn/HsUtils.hs
index 35f146b..4eb85cb 100644
--- a/compiler/hsSyn/HsUtils.hs
+++ b/compiler/hsSyn/HsUtils.hs
@@ -188,7 +188,7 @@ mkHsLams tyvars dicts expr = mkLHsWrap (mkWpTyLams tyvars
mkHsConApp :: DataCon -> [Type] -> [HsExpr Id] -> LHsExpr Id
-- Used for constructing dictionary terms etc, so no locations
mkHsConApp data_con tys args
- = foldl mk_app (nlHsTyApp (dataConWrapId data_con) tys) args
+ = foldl' mk_app (nlHsTyApp (dataConWrapId data_con) tys) args
where
mk_app f a = noLoc (HsApp f (noLoc a))
@@ -201,7 +201,7 @@ nlHsTyApp :: name -> [Type] -> LHsExpr name
nlHsTyApp fun_id tys = noLoc (HsWrap (mkWpTyApps tys) (HsVar (noLoc fun_id)))
nlHsTyApps :: name -> [Type] -> [LHsExpr name] -> LHsExpr name
-nlHsTyApps fun_id tys xs = foldl nlHsApp (nlHsTyApp fun_id tys) xs
+nlHsTyApps fun_id tys xs = foldl' nlHsApp (nlHsTyApp fun_id tys) xs
--------- Adding parens ---------
mkLHsPar :: LHsExpr name -> LHsExpr name
@@ -385,20 +385,20 @@ nlHsSyntaxApps (SyntaxExpr { syn_expr = fun
, syn_res_wrap = res_wrap }) args
| [] <- arg_wraps -- in the noSyntaxExpr case
= ASSERT( isIdHsWrapper res_wrap )
- foldl nlHsApp (noLoc fun) args
+ foldl' nlHsApp (noLoc fun) args
| otherwise
- = mkLHsWrap res_wrap (foldl nlHsApp (noLoc fun) (zipWithEqual "nlHsSyntaxApps"
+ = mkLHsWrap res_wrap (foldl' nlHsApp (noLoc fun) (zipWithEqual "nlHsSyntaxApps"
mkLHsWrap arg_wraps args))
nlHsIntLit :: Integer -> LHsExpr id
nlHsIntLit n = noLoc (HsLit (HsInt (show n) n))
nlHsApps :: id -> [LHsExpr id] -> LHsExpr id
-nlHsApps f xs = foldl nlHsApp (nlHsVar f) xs
+nlHsApps f xs = foldl' nlHsApp (nlHsVar f) xs
nlHsVarApps :: id -> [id] -> LHsExpr id
-nlHsVarApps f xs = noLoc (foldl mk (HsVar (noLoc f)) (map (HsVar . noLoc) xs))
+nlHsVarApps f xs = noLoc (foldl' mk (HsVar (noLoc f)) (map (HsVar . noLoc) xs))
where
mk f a = HsApp (noLoc f) (noLoc a)
@@ -463,7 +463,7 @@ nlHsTyVar x = noLoc (HsTyVar (noLoc x))
nlHsFunTy a b = noLoc (HsFunTy a b)
nlHsTyConApp :: name -> [LHsType name] -> LHsType name
-nlHsTyConApp tycon tys = foldl nlHsAppTy (nlHsTyVar tycon) tys
+nlHsTyConApp tycon tys = foldl' nlHsAppTy (nlHsTyVar tycon) tys
{-
Tuples. All these functions are *pre-typechecker* because they lack
diff --git a/compiler/iface/IfaceEnv.hs b/compiler/iface/IfaceEnv.hs
index 20b497b..e22613c 100644
--- a/compiler/iface/IfaceEnv.hs
+++ b/compiler/iface/IfaceEnv.hs
@@ -38,7 +38,7 @@ import SrcLoc
import Util
import Outputable
-import Data.List ( partition )
+import Data.List ( partition, foldl' )
{-
*********************************************************
@@ -246,7 +246,7 @@ initNameCache us names
nsNames = initOrigNames names }
initOrigNames :: [Name] -> OrigNameCache
-initOrigNames names = foldl extendOrigNameCache emptyModuleEnv names
+initOrigNames names = foldl' extendOrigNameCache emptyModuleEnv names
{-
************************************************************************
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
index 46a4990..ba9e8ce 100644
--- a/compiler/main/GhcMake.hs
+++ b/compiler/main/GhcMake.hs
@@ -608,9 +608,9 @@ checkStability
-> ([ModuleName], -- stableObject
[ModuleName]) -- stableBCO
-checkStability hpt sccs all_home_mods = foldl checkSCC ([],[]) sccs
+checkStability hpt sccs all_home_mods = foldl' checkSCC ([],[]) sccs
where
- checkSCC (stable_obj, stable_bco) scc0
+ checkSCC (!stable_obj, !stable_bco) scc0
| stableObjects = (scc_mods ++ stable_obj, stable_bco)
| stableBCOs = (stable_obj, scc_mods ++ stable_bco)
| otherwise = (stable_obj, stable_bco)
@@ -1011,7 +1011,7 @@ parUpsweep_one mod home_mod_map comp_graph_loops lcl_dflags cleanup par_sem
, this_build_mod `notElem` loop ]
- let all_deps = foldl1 Set.union [textual_deps, int_loop_deps, ext_loop_deps]
+ let all_deps = foldl1' Set.union [textual_deps, int_loop_deps, ext_loop_deps]
-- All of the module's home-module dependencies.
let home_deps_with_idx =
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index d778b1d..355c60e 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -209,8 +209,8 @@ allKnownKeyNames -- where templateHaskellNames are defined
all_names = knownKeyNames
++ templateHaskellNames
- namesEnv = foldl (\m n -> extendNameEnv_Acc (:) singleton m n n)
- emptyUFM all_names
+ namesEnv = foldl' (\m n -> extendNameEnv_Acc (:) singleton m n n)
+ emptyUFM all_names
badNamesEnv = filterNameEnv (\ns -> length ns > 1) namesEnv
badNamesPairs = nameEnvUniqueElts badNamesEnv
badNamesStrs = map pairToStr badNamesPairs
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index 800958b..c8bd6ba 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -191,6 +191,7 @@ import Util
import GHC.Serialized ( Serialized )
import Foreign
+import Data.Foldable ( foldl' )
import Control.Monad ( guard, liftM, when, ap )
import Data.IORef
import Data.Time
@@ -1504,7 +1505,7 @@ icExtendGblRdrEnv env tythings
| is_sub_bndr thing
= env
| otherwise
- = foldl extendGlobalRdrEnv env1 (concatMap localGREsFromAvail avail)
+ = foldl' extendGlobalRdrEnv env1 (concatMap localGREsFromAvail avail)
where
env1 = shadowNames env (concatMap availNames avail)
avail = tyThingAvailInfo thing
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index 2655c45..96729f5 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -305,7 +305,7 @@ searchPackageId dflags pid = filter ((pid ==) . sourcePackageId)
extendPackageConfigMap
:: PackageConfigMap -> [PackageConfig] -> PackageConfigMap
extendPackageConfigMap pkg_map new_pkgs
- = foldl add pkg_map new_pkgs
+ = foldl' add pkg_map new_pkgs
where add pkg_map p = addToUFM pkg_map (packageConfigId p) p
-- | Looks up the package with the given id in the package state, panicing if it is
diff --git a/compiler/nativeGen/AsmCodeGen.hs b/compiler/nativeGen/AsmCodeGen.hs
index 6bb7f8a..ed1d1ff 100644
--- a/compiler/nativeGen/AsmCodeGen.hs
+++ b/compiler/nativeGen/AsmCodeGen.hs
@@ -312,7 +312,7 @@ finishNativeGen dflags modLoc bufh@(BufHandle _ _ h) us ngs
-- build the global register conflict graph
let graphGlobal
- = foldl Color.union Color.initGraph
+ = foldl' Color.union Color.initGraph
$ [ Color.raGraph stat
| stat@Color.RegAllocStatsStart{} <- stats]
@@ -863,8 +863,8 @@ build_mapping ncgImpl (CmmProc info lbl live (ListGraph (head:blocks)))
-- find all the blocks that just consist of a jump that can be
-- shorted.
-- Don't completely eliminate loops here -- that can leave a dangling jump!
- (_, shortcut_blocks, others) = foldl split (emptyBlockSet, [], []) blocks
- split (s, shortcut_blocks, others) b@(BasicBlock id [insn])
+ (_, shortcut_blocks, others) = foldl' split (emptyBlockSet, [], []) blocks
+ split (!s, !shortcut_blocks, !others) b@(BasicBlock id [insn])
| Just jd <- canShortcut ncgImpl insn,
Just dest <- getJumpDestBlockId ncgImpl jd,
not (has_info id),
@@ -880,8 +880,7 @@ build_mapping ncgImpl (CmmProc info lbl live (ListGraph (head:blocks)))
has_info l = mapMember l info
-- build a mapping from BlockId to JumpDest for shorting branches
- mapping = foldl add emptyUFM shortcut_blocks
- add ufm (id,dest) = addToUFM ufm id dest
+ mapping = listToUFM shortcut_blocks
apply_mapping :: NcgImpl statics instr jumpDest
-> UniqFM jumpDest
diff --git a/compiler/rename/RnNames.hs b/compiler/rename/RnNames.hs
index 40049bf..87aaf53 100644
--- a/compiler/rename/RnNames.hs
+++ b/compiler/rename/RnNames.hs
@@ -54,7 +54,7 @@ import Data.Either ( partitionEithers, isRight, rights )
import Data.Map ( Map )
import qualified Data.Map as Map
import Data.Ord ( comparing )
-import Data.List ( partition, (\\), find, sortBy )
+import Data.List ( partition, (\\), find, sortBy, foldl' )
-- import qualified Data.Set as Set
import System.FilePath ((</>))
import System.IO
@@ -482,7 +482,7 @@ extendGlobalRdrEnvRn avails new_fixities
; rdr_env2 <- foldlM add_gre rdr_env1 new_gres
- ; let fix_env' = foldl extend_fix_env fix_env new_gres
+ ; let fix_env' = foldl' extend_fix_env fix_env new_gres
gbl_env' = gbl_env { tcg_rdr_env = rdr_env2, tcg_fix_env = fix_env' }
; traceRn (text "extendGlobalRdrEnvRn 2" <+> (pprGlobalRdrEnv True rdr_env2))
@@ -1105,7 +1105,7 @@ classifyGRE gre = case gre_par gre of
-- will give Ix(Ix,index,range) and Ix(index)
-- We want to combine these; addAvail does that
nubAvails :: [AvailInfo] -> [AvailInfo]
-nubAvails avails = nameEnvElts (foldl add emptyNameEnv avails)
+nubAvails avails = nameEnvElts (foldl' add emptyNameEnv avails)
where
add env avail = extendNameEnv_C plusAvail env (availName avail) avail
diff --git a/compiler/simplCore/CallArity.hs b/compiler/simplCore/CallArity.hs
index e172aef..2cf28a0 100644
--- a/compiler/simplCore/CallArity.hs
+++ b/compiler/simplCore/CallArity.hs
@@ -20,6 +20,7 @@ import CoreUtils ( exprIsHNF, exprIsTrivial )
import UnVarGraph
import Demand
+import Data.Foldable ( foldl' )
import Control.Arrow ( first, second )
@@ -725,4 +726,4 @@ lubArityEnv :: VarEnv Arity -> VarEnv Arity -> VarEnv Arity
lubArityEnv = plusVarEnv_C min
lubRess :: [CallArityRes] -> CallArityRes
-lubRess = foldl lubRes emptyArityRes
+lubRess = foldl' lubRes emptyArityRes
diff --git a/compiler/simplCore/FloatIn.hs b/compiler/simplCore/FloatIn.hs
index f32b5a3..d315d64 100644
--- a/compiler/simplCore/FloatIn.hs
+++ b/compiler/simplCore/FloatIn.hs
@@ -30,7 +30,7 @@ import VarSet
import Util
import DynFlags
import Outputable
-import Data.List( mapAccumL )
+import Data.List ( mapAccumL, foldl' )
{-
Top-level interface function, @floatInwards@. Note that we do not
@@ -426,9 +426,9 @@ fiExpr dflags to_drop (_, AnnCase scrut case_bndr ty alts)
alts_ty_fvs = map alt_ty_fvs alts
all_alts_ty_fvs = unionDVarSets alts_ty_fvs
alt_fvs (_con, args, rhs)
- = foldl delDVarSet (freeVarsOf rhs) (case_bndr:args)
+ = foldl' delDVarSet (freeVarsOf rhs) (case_bndr:args)
alt_ty_fvs (_con, args, rhs)
- = foldl delDVarSet (freeVarsOfType rhs) (case_bndr:args)
+ = foldl' delDVarSet (freeVarsOfType rhs) (case_bndr:args)
-- Delete case_bndr and args from free vars of rhs
-- to get free vars of alt
diff --git a/compiler/simplCore/SetLevels.hs b/compiler/simplCore/SetLevels.hs
index 86442ab..c62bf4b 100644
--- a/compiler/simplCore/SetLevels.hs
+++ b/compiler/simplCore/SetLevels.hs
@@ -87,6 +87,8 @@ import FastString
import UniqDFM (udfmToUfm)
import FV
+import Data.Foldable ( foldl' )
+
{-
************************************************************************
* *
@@ -312,7 +314,7 @@ lvlExpr env expr@(_, AnnApp _ _) = do
let (lapp, rargs) = left (n_val_args - arity) expr []
rargs' <- mapM (lvlMFE False env) rargs
lapp' <- lvlMFE False env lapp
- return (foldl App lapp' rargs')
+ return (foldl' App lapp' rargs')
where
n_val_args = count (isValArg . deAnnotate) args
arity = idArity f
@@ -331,7 +333,7 @@ lvlExpr env expr@(_, AnnApp _ _) = do
_otherwise -> do
args' <- mapM (lvlMFE False env) args
fun' <- lvlExpr env fun
- return (foldl App fun' args')
+ return (foldl' App fun' args')
-- We don't split adjacent lambdas. That is, given
-- \x y -> (x+1,y)
@@ -833,7 +835,7 @@ substBndrsSL :: RecFlag -> LevelEnv -> [InVar] -> (LevelEnv, [OutVar])
-- So named only to avoid the name clash with CoreSubst.substBndrs
substBndrsSL is_rec env@(LE { le_subst = subst, le_env = id_env }) bndrs
= ( env { le_subst = subst'
- , le_env = foldl add_id id_env (bndrs `zip` bndrs') }
+ , le_env = foldl' add_id id_env (bndrs `zip` bndrs') }
, bndrs')
where
(subst', bndrs') = case is_rec of
@@ -973,7 +975,7 @@ addLvl :: Level -> VarEnv Level -> OutVar -> VarEnv Level
addLvl dest_lvl env v' = extendVarEnv env v' dest_lvl
addLvls :: Level -> VarEnv Level -> [OutVar] -> VarEnv Level
-addLvls dest_lvl env vs = foldl (addLvl dest_lvl) env vs
+addLvls dest_lvl env vs = foldl' (addLvl dest_lvl) env vs
floatLams :: LevelEnv -> Maybe Int
floatLams le = floatOutLambdas (le_switches le)
@@ -1080,8 +1082,8 @@ newPolyBndrs dest_lvl
; let new_bndrs = zipWith mk_poly_bndr bndrs uniqs
bndr_prs = bndrs `zip` new_bndrs
env' = env { le_lvl_env = addLvls dest_lvl lvl_env new_bndrs
- , le_subst = foldl add_subst subst bndr_prs
- , le_env = foldl add_id id_env bndr_prs }
+ , le_subst = foldl' add_subst subst bndr_prs
+ , le_env = foldl' add_id id_env bndr_prs }
; return (env', new_bndrs) }
where
add_subst env (v, v') = extendIdSubst env v (mkVarApps (Var v') abs_vars)
@@ -1116,7 +1118,7 @@ cloneCaseBndrs env@(LE { le_subst = subst, le_lvl_env = lvl_env, le_env = id_env
env' = env { le_ctxt_lvl = new_lvl
, le_lvl_env = addLvls new_lvl lvl_env vs'
, le_subst = subst'
- , le_env = foldl add_id id_env (vs `zip` vs') }
+ , le_env = foldl' add_id id_env (vs `zip` vs') }
; return (env', vs') }
@@ -1136,7 +1138,7 @@ cloneLetVars is_rec
prs = vs `zip` vs2
env' = env { le_lvl_env = addLvls dest_lvl lvl_env vs2
, le_subst = subst'
- , le_env = foldl add_id id_env prs }
+ , le_env = foldl' add_id id_env prs }
; return (env', vs2) }
diff --git a/compiler/specialise/Rules.hs b/compiler/specialise/Rules.hs
index f9f195f..2a68452 100644
--- a/compiler/specialise/Rules.hs
+++ b/compiler/specialise/Rules.hs
@@ -347,7 +347,7 @@ mkRuleBase rules = extendRuleBaseList emptyRuleBase rules
extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase
extendRuleBaseList rule_base new_guys
- = foldl extendRuleBase rule_base new_guys
+ = foldl' extendRuleBase rule_base new_guys
unionRuleBase :: RuleBase -> RuleBase -> RuleBase
unionRuleBase rb1 rb2 = plusNameEnv_C (++) rb1 rb2
@@ -846,7 +846,7 @@ match_alts renv subst ((c1,vs1,r1):alts1) ((c2,vs2,r2):alts2)
= do { subst1 <- match renv' subst r1 r2
; match_alts renv subst1 alts1 alts2 }
where
- renv' = foldl mb renv (vs1 `zip` vs2)
+ renv' = foldl' mb renv (vs1 `zip` vs2)
mb renv (v1,v2) = rnMatchBndr2 renv subst v1 v2
match_alts _ _ _ _
diff --git a/compiler/specialise/Specialise.hs b/compiler/specialise/Specialise.hs
index 09caa00..7dcd66e 100644
--- a/compiler/specialise/Specialise.hs
+++ b/compiler/specialise/Specialise.hs
@@ -40,6 +40,7 @@ import Control.Monad
#if __GLASGOW_HASKELL__ > 710
import qualified Control.Monad.Fail as MonadFail
#endif
+import Data.Foldable ( foldl' )
import Data.Map (Map)
import qualified Data.Map as Map
import qualified FiniteMap as Map
@@ -1942,7 +1943,7 @@ mkDB bind = (bind, bind_fvs bind)
-- | Identify the free variables of a 'CoreBind'
bind_fvs :: CoreBind -> VarSet
bind_fvs (NonRec bndr rhs) = pair_fvs (bndr,rhs)
-bind_fvs (Rec prs) = foldl delVarSet rhs_fvs bndrs
+bind_fvs (Rec prs) = foldl' delVarSet rhs_fvs bndrs
where
bndrs = map fst prs
rhs_fvs = unionVarSets (map pair_fvs prs)
diff --git a/compiler/stranal/DmdAnal.hs b/compiler/stranal/DmdAnal.hs
index 53144ff..0d875c7 100644
--- a/compiler/stranal/DmdAnal.hs
+++ b/compiler/stranal/DmdAnal.hs
@@ -543,7 +543,7 @@ dmdAnalRhs top_lvl rec_flag env id rhs
= (sig_ty, lazy_fv, id', mkLams bndrs' body')
where
(bndrs, body) = collectBinders rhs
- env_body = foldl extendSigsWithLam env bndrs
+ env_body = foldl' extendSigsWithLam env bndrs
(body_ty, body') = dmdAnal env_body body_dmd body
body_ty' = removeDmdTyArgs body_ty -- zap possible deep CPR info
(DmdType rhs_fv rhs_dmds rhs_res, bndrs')
@@ -1028,7 +1028,7 @@ extendSigsWithLam env id
extendEnvForProdAlt :: AnalEnv -> CoreExpr -> Id -> DataCon -> [Var] -> AnalEnv
-- See Note [CPR in a product case alternative]
extendEnvForProdAlt env scrut case_bndr dc bndrs
- = foldl do_con_arg env1 ids_w_strs
+ = foldl' do_con_arg env1 ids_w_strs
where
env1 = extendAnalEnv NotTopLevel env case_bndr case_bndr_sig
diff --git a/compiler/typecheck/FunDeps.hs b/compiler/typecheck/FunDeps.hs
index 4f213b2..d316585 100644
--- a/compiler/typecheck/FunDeps.hs
+++ b/compiler/typecheck/FunDeps.hs
@@ -36,7 +36,7 @@ import Util
import Pair ( Pair(..) )
import Data.List ( nubBy )
import Data.Maybe
-import Data.Foldable ( fold )
+import Data.Foldable ( fold, foldl' )
{-
************************************************************************
@@ -500,7 +500,7 @@ oclose preds fixed_tvs
| null tv_fds = fixed_tvs -- Fast escape hatch for common case.
| otherwise = fixVarSet extend fixed_tvs
where
- extend fixed_tvs = foldl add fixed_tvs tv_fds
+ extend fixed_tvs = foldl' add fixed_tvs tv_fds
where
add fixed_tvs (ls,rs)
| ls `subVarSet` fixed_tvs = fixed_tvs `unionVarSet` closeOverKinds rs
diff --git a/compiler/typecheck/TcBinds.hs b/compiler/typecheck/TcBinds.hs
index 1b16da1..b7fb6a6 100644
--- a/compiler/typecheck/TcBinds.hs
+++ b/compiler/typecheck/TcBinds.hs
@@ -60,6 +60,7 @@ import PrelNames( mkUnboundName, gHC_PRIM, ipClassName )
import TcValidity (checkValidType)
import qualified GHC.LanguageExtensions as LangExt
+import Data.Foldable ( foldl' )
import Control.Monad
#include "HsVersions.h"
@@ -1102,7 +1103,7 @@ Some wrinkles
mkPragEnv :: [LSig Name] -> LHsBinds Name -> TcPragEnv
mkPragEnv sigs binds
- = foldl extendPragEnv emptyNameEnv prs
+ = foldl' extendPragEnv emptyNameEnv prs
where
prs = mapMaybe get_sig sigs
diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs
index a4c8d02..63cebfc 100644
--- a/compiler/typecheck/TcExpr.hs
+++ b/compiler/typecheck/TcExpr.hs
@@ -1067,7 +1067,7 @@ tcApp1 :: HsExpr Name -- either HsApp or HsAppType
-> ExpRhoType -> TcM (HsExpr TcId)
tcApp1 e res_ty
= do { (wrap, fun, args) <- tcApp Nothing (noLoc e) [] res_ty
- ; return (mkHsWrap wrap $ unLoc $ foldl mk_hs_app fun args) }
+ ; return (mkHsWrap wrap $ unLoc $ foldl' mk_hs_app fun args) }
where
mk_hs_app f (Left a) = mkHsApp f a
mk_hs_app f (Right a) = mkHsAppTypeOut f a
@@ -1120,7 +1120,7 @@ tcApp m_herald orig_fun orig_args res_ty
-- up to call that function
; wrap_res <- addFunResCtxt True (unLoc fun) actual_res_ty res_ty $
tcSubTypeDS_NC_O orig GenSigCtxt
- (Just $ foldl mk_hs_app fun args)
+ (Just $ foldl' mk_hs_app fun args)
actual_res_ty res_ty
; return (wrap_res, mkLHsWrap wrap_fun fun1, args1) }
@@ -2471,7 +2471,7 @@ missingFields con fields
= text "Fields of" <+> quotes (ppr con) <+> ptext (sLit "not initialised:")
<+> pprWithCommas ppr fields
--- callCtxt fun args = text "In the call" <+> parens (ppr (foldl mkHsApp fun args))
+-- callCtxt fun args = text "In the call" <+> parens (ppr (foldl' mkHsApp fun args))
noPossibleParents :: [LHsRecUpdField Name] -> SDoc
noPossibleParents rbinds
diff --git a/compiler/typecheck/TcGenDeriv.hs b/compiler/typecheck/TcGenDeriv.hs
index 15f0480..772d1be 100644
--- a/compiler/typecheck/TcGenDeriv.hs
+++ b/compiler/typecheck/TcGenDeriv.hs
@@ -69,7 +69,7 @@ import TcEnv (InstInfo)
import StaticFlags( opt_PprStyle_Debug )
import ListSetOps ( assocMaybe )
-import Data.List ( partition, intersperse )
+import Data.List ( partition, intersperse, foldl' )
import Data.Maybe ( catMaybes, isJust )
type BagDerivStuff = Bag DerivStuff
@@ -244,7 +244,7 @@ gen_Eq_binds loc tycon
where
nested_eq_expr [] [] [] = true_Expr
nested_eq_expr tys as bs
- = foldl1 and_Expr (zipWith3Equal "nested_eq" nested_eq tys as bs)
+ = foldl1' and_Expr (zipWith3Equal "nested_eq" nested_eq tys as bs)
where
nested_eq ty a b = nlHsPar (eq_Expr tycon ty (nlHsVar a) (nlHsVar b))
@@ -860,7 +860,7 @@ gen_Ix_binds loc tycon
= mk_easy_FunBind loc inRange_RDR
[nlTuplePat [con_pat as_needed, con_pat bs_needed] Boxed,
con_pat cs_needed] $
- foldl1 and_Expr (zipWith3Equal "single_con_inRange" in_range as_needed bs_needed cs_needed)
+ foldl1' and_Expr (zipWith3Equal "single_con_inRange" in_range as_needed bs_needed cs_needed)
where
in_range a b c = nlHsApps inRange_RDR [mkLHsVarTuple [a,b], nlHsVar c]
@@ -1325,7 +1325,7 @@ gen_Data_binds dflags loc rep_tc
gfoldl_eqn con
= ([nlVarPat k_RDR, nlVarPat z_RDR, nlConVarPat con_name as_needed],
- foldl mk_k_app (nlHsVar z_RDR `nlHsApp` nlHsVar con_name) as_needed)
+ foldl' mk_k_app (nlHsVar z_RDR `nlHsApp` nlHsVar con_name) as_needed)
where
con_name :: RdrName
con_name = getRdrName con
@@ -2026,7 +2026,7 @@ gen_Traversable_binds loc tycon
-- fmap (\b1 b2 ... -> Con b1 b2 ...) x1 <*> x2 <*> ..
mkApCon :: LHsExpr RdrName -> [LHsExpr RdrName] -> LHsExpr RdrName
mkApCon con [] = nlHsApps pure_RDR [con]
- mkApCon con (x:xs) = foldl appAp (nlHsApps fmap_RDR [con,x]) xs
+ mkApCon con (x:xs) = foldl' appAp (nlHsApps fmap_RDR [con,x]) xs
where appAp x y = nlHsApps ap_RDR [x,y]
{-
@@ -2108,7 +2108,7 @@ gen_Lift_binds loc tycon
lift_Expr
| is_infix = nlHsApps infixApp_RDR [a1, conE_Expr, a2]
- | otherwise = foldl mk_appE_app conE_Expr lifted_as
+ | otherwise = foldl' mk_appE_app conE_Expr lifted_as
(a1:a2:_) = lifted_as
mk_appE_app :: LHsExpr RdrName -> LHsExpr RdrName -> LHsExpr RdrName
diff --git a/compiler/typecheck/TcInstDcls.hs b/compiler/typecheck/TcInstDcls.hs
index 59ddaee..1a8b9e2 100644
--- a/compiler/typecheck/TcInstDcls.hs
+++ b/compiler/typecheck/TcInstDcls.hs
@@ -61,6 +61,7 @@ import Util
import BooleanFormula ( isUnsatisfied, pprBooleanFormulaNice )
import qualified GHC.LanguageExtensions as LangExt
+import Data.Foldable ( foldl' )
import Control.Monad
import Maybes
@@ -829,7 +830,7 @@ tcInstDecl2 (InstInfo { iSpec = ispec, iBinds = ibinds })
-- NB: We *can* have covars in inst_tys, in the case of
-- promoted GADT constructors.
- con_app_args = foldl app_to_meth con_app_tys sc_meth_ids
+ con_app_args = foldl' app_to_meth con_app_tys sc_meth_ids
app_to_meth :: HsExpr Id -> Id -> HsExpr Id
app_to_meth fun meth_id = L loc fun `HsApp` L loc (wrapId arg_wrapper meth_id)
diff --git a/compiler/typecheck/TcPatSyn.hs b/compiler/typecheck/TcPatSyn.hs
index 002ab04..1eb52b0 100644
--- a/compiler/typecheck/TcPatSyn.hs
+++ b/compiler/typecheck/TcPatSyn.hs
@@ -49,7 +49,7 @@ import Bag
import Util
import ErrUtils
import Control.Monad ( unless, zipWithM )
-import Data.List( partition )
+import Data.List( partition, foldl' )
#include "HsVersions.h"
@@ -539,7 +539,7 @@ tcPatSynMatcher (L loc name) lpat
-- See Note [Exported LocalIds] in Id
inst_wrap = mkWpEvApps prov_dicts <.> mkWpTyApps ex_tys
- cont' = foldl nlHsApp (mkLHsWrap inst_wrap (nlHsVar cont)) cont_args
+ cont' = foldl' nlHsApp (mkLHsWrap inst_wrap (nlHsVar cont)) cont_args
fail' = nlHsApps fail [nlHsVar voidPrimId]
@@ -764,8 +764,8 @@ tcPatToExpr args pat = go pat
mkPrefixConExpr :: Located Name -> [LPat Name] -> Either MsgDoc (HsExpr Name)
mkPrefixConExpr lcon@(L loc _) pats
= do { exprs <- mapM go pats
- ; return (foldl (\x y -> HsApp (L loc x) y)
- (HsVar lcon) exprs) }
+ ; return (foldl' (\x y -> HsApp (L loc x) y)
+ (HsVar lcon) exprs) }
mkRecordConExpr :: Located Name -> HsRecFields Name (LPat Name)
-> Either MsgDoc (HsExpr Name)
diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs
index dc05c13..50c26ec 100644
--- a/compiler/typecheck/TcRnTypes.hs
+++ b/compiler/typecheck/TcRnTypes.hs
@@ -172,6 +172,7 @@ import ListSetOps
import FastString
import qualified GHC.LanguageExtensions as LangExt
+import Data.Foldable ( foldl' )
import Control.Monad (ap, liftM, msum)
#if __GLASGOW_HASKELL__ > 710
import qualified Control.Monad.Fail as MonadFail
@@ -1080,7 +1081,7 @@ data ImportAvails
mkModDeps :: [(ModuleName, IsBootInterface)]
-> ModuleNameEnv (ModuleName, IsBootInterface)
-mkModDeps deps = foldl add emptyUFM deps
+mkModDeps deps = foldl' add emptyUFM deps
where
add env elt@(m,_) = addToUFM env m elt
diff --git a/compiler/typecheck/TcSplice.hs b/compiler/typecheck/TcSplice.hs
index 5483d0d..e2b0256 100644
--- a/compiler/typecheck/TcSplice.hs
+++ b/compiler/typecheck/TcSplice.hs
@@ -125,6 +125,7 @@ import Data.Binary.Get
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as LB
import Data.Dynamic ( fromDynamic, toDyn )
+import Data.Foldable ( foldl' )
import qualified Data.Map as Map
import Data.Typeable ( typeOf, Typeable, TypeRep, typeRep )
import Data.Data (Data)
@@ -1887,7 +1888,7 @@ reifyModule (TH.Module (TH.PkgName pkgString) (TH.ModName mString)) = do
------------------------------
mkThAppTs :: TH.Type -> [TH.Type] -> TH.Type
-mkThAppTs fun_ty arg_tys = foldl TH.AppT fun_ty arg_tys
+mkThAppTs fun_ty arg_tys = foldl' TH.AppT fun_ty arg_tys
noTH :: LitString -> SDoc -> TcM a
noTH s d = failWithTc (hsep [text "Can't represent" <+> ptext s <+>
diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs
index 94ab0bc..861e88f 100644
--- a/compiler/typecheck/TcType.hs
+++ b/compiler/typecheck/TcType.hs
@@ -222,6 +222,7 @@ import FV
import qualified GHC.LanguageExtensions as LangExt
import Data.IORef
+import Data.Foldable ( foldl' )
import Control.Monad (liftM, ap)
import Data.Functor.Identity
@@ -1191,7 +1192,7 @@ mkNakedAppTys :: Type -> [Type] -> Type
-- See Note [Type-checking inside the knot] in TcHsType
mkNakedAppTys ty1 [] = ty1
mkNakedAppTys (TyConApp tc tys1) tys2 = mkNakedTyConApp tc (tys1 ++ tys2)
-mkNakedAppTys ty1 tys2 = foldl AppTy ty1 tys2
+mkNakedAppTys ty1 tys2 = foldl' AppTy ty1 tys2
mkNakedAppTy :: Type -> Type -> Type
-- See Note [Type-checking inside the knot] in TcHsType
diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs
index d9f43d3..e6f5850fc 100644
--- a/compiler/typecheck/TcValidity.hs
+++ b/compiler/typecheck/TcValidity.hs
@@ -3,7 +3,7 @@
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998
-}
-{-# LANGUAGE CPP, TupleSections, ViewPatterns #-}
+{-# LANGUAGE CPP, TupleSections, ViewPatterns, BangPatterns #-}
module TcValidity (
Rank, UserTypeCtxt(..), checkValidType, checkValidMonoType,
@@ -62,7 +62,7 @@ import Unique ( mkAlphaTyVarUnique )
import qualified GHC.LanguageExtensions as LangExt
import Control.Monad
-import Data.List ( (\\) )
+import Data.List ( (\\), foldl' )
{-
************************************************************************
@@ -1575,14 +1575,14 @@ checkValidCoAxiom ax@(CoAxiom { co_ax_tc = fam_tc, co_ax_branches = branches })
check_injectivity prev_branches cur_branch
| Injective inj <- injectivity
= do { let conflicts =
- fst $ foldl (gather_conflicts inj prev_branches cur_branch)
- ([], 0) prev_branches
+ fst $ foldl' (gather_conflicts inj prev_branches cur_branch)
+ ([], 0) prev_branches
; mapM_ (\(err, span) -> setSrcSpan span $ addErr err)
(makeInjectivityErrors ax cur_branch inj conflicts) }
| otherwise
= return ()
- gather_conflicts inj prev_branches cur_branch (acc, n) branch
+ gather_conflicts inj prev_branches cur_branch (!acc, !n) branch
-- n is 0-based index of branch in prev_branches
= case injectiveBranches inj cur_branch branch of
InjectivityUnified ax1 ax2
diff --git a/compiler/types/Coercion.hs b/compiler/types/Coercion.hs
index a515d29..f236ca8 100644
--- a/compiler/types/Coercion.hs
+++ b/compiler/types/Coercion.hs
@@ -123,8 +123,9 @@ import TysPrim ( eqPhantPrimTyCon )
import ListSetOps
import Maybes
-import Control.Monad (foldM)
+import Control.Monad ( foldM )
import Control.Arrow ( first )
+import Data.Foldable ( foldl' )
import Data.Function ( on )
{-
@@ -615,7 +616,7 @@ mkAppCo co arg = AppCo co arg
mkAppCos :: Coercion
-> [Coercion]
-> Coercion
-mkAppCos co1 cos = foldl mkAppCo co1 cos
+mkAppCos co1 cos = foldl' mkAppCo co1 cos
-- | Like `mkAppCo`, but allows the second coercion to be other than
-- nominal. See Note [mkTransAppCo]. Role r3 cannot be more stringent
@@ -693,9 +694,9 @@ mkForAllCo tv kind_co co
mkForAllCos :: [(TyVar, Coercion)] -> Coercion -> Coercion
mkForAllCos bndrs (Refl r ty)
= let (refls_rev'd, non_refls_rev'd) = span (isReflCo . snd) (reverse bndrs) in
- foldl (flip $ uncurry ForAllCo)
- (Refl r $ mkInvForAllTys (reverse (map fst refls_rev'd)) ty)
- non_refls_rev'd
+ foldl' (flip $ uncurry ForAllCo)
+ (Refl r $ mkInvForAllTys (reverse (map fst refls_rev'd)) ty)
+ non_refls_rev'd
mkForAllCos bndrs co = foldr (uncurry ForAllCo) co bndrs
-- | Make a Coercion quantified over a type variable;
diff --git a/compiler/types/FamInstEnv.hs b/compiler/types/FamInstEnv.hs
index 62906dd..a527b2e 100644
--- a/compiler/types/FamInstEnv.hs
+++ b/compiler/types/FamInstEnv.hs
@@ -60,6 +60,7 @@ import SrcLoc
import FastString
import MonadUtils
import Control.Monad
+import Data.Foldable ( foldl' )
import Data.Function ( on )
import Data.List( mapAccumL )
@@ -395,7 +396,7 @@ familyInstances (pkg_fie, home_fie) fam
Nothing -> []
extendFamInstEnvList :: FamInstEnv -> [FamInst] -> FamInstEnv
-extendFamInstEnvList inst_env fis = foldl extendFamInstEnv inst_env fis
+extendFamInstEnvList inst_env fis = foldl' extendFamInstEnv inst_env fis
extendFamInstEnv :: FamInstEnv -> FamInst -> FamInstEnv
extendFamInstEnv inst_env
diff --git a/compiler/types/InstEnv.hs b/compiler/types/InstEnv.hs
index 6b57f5c..5b484e6 100644
--- a/compiler/types/InstEnv.hs
+++ b/compiler/types/InstEnv.hs
@@ -44,6 +44,7 @@ import BasicTypes
import UniqFM
import Util
import Id
+import Data.Foldable ( foldl' )
import Data.Data ( Data, Typeable )
import Data.Maybe ( isJust, isNothing )
@@ -400,7 +401,7 @@ memberInstEnv inst_env ins_item@(ClsInst { is_cls_nm = cls_nm } ) =
(lookupUFM inst_env cls_nm)
extendInstEnvList :: InstEnv -> [ClsInst] -> InstEnv
-extendInstEnvList inst_env ispecs = foldl extendInstEnv inst_env ispecs
+extendInstEnvList inst_env ispecs = foldl' extendInstEnv inst_env ispecs
extendInstEnv :: InstEnv -> ClsInst -> InstEnv
extendInstEnv inst_env ins_item@(ClsInst { is_cls_nm = cls_nm })
diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs
index 4cdd883..8650cb2 100644
--- a/compiler/types/TyCoRep.hs
+++ b/compiler/types/TyCoRep.hs
@@ -2641,7 +2641,7 @@ ppr_type p (AppTy t1 t2)
split_app_tys head args = (head, args)
mk_app_tys (TyConApp tc tys1) tys2 = TyConApp tc (tys1 ++ tys2)
- mk_app_tys ty1 tys2 = foldl AppTy ty1 tys2
+ mk_app_tys ty1 tys2 = foldl' AppTy ty1 tys2
ppr_type p (CastTy ty co)
= if_print_coercions
diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs
index 49c7267..0b78b77 100644
--- a/compiler/types/Type.hs
+++ b/compiler/types/Type.hs
@@ -225,6 +225,7 @@ import ListSetOps
import Digraph
import Maybes ( orElse )
+import Data.Foldable ( foldl' )
import Data.Maybe ( isJust, mapMaybe )
import Control.Monad ( guard )
import Control.Arrow ( first, second )
@@ -630,7 +631,7 @@ mkAppTy ty1 ty2 = AppTy ty1 ty2
mkAppTys :: Type -> [Type] -> Type
mkAppTys ty1 [] = ty1
mkAppTys (TyConApp tc tys1) tys2 = mkTyConApp tc (tys1 ++ tys2)
-mkAppTys ty1 tys2 = foldl AppTy ty1 tys2
+mkAppTys ty1 tys2 = foldl' AppTy ty1 tys2
-------------
splitAppTy_maybe :: Type -> Maybe (Type, Type)
diff --git a/compiler/utils/Bag.hs b/compiler/utils/Bag.hs
index 09fddcc..46bf1f7 100644
--- a/compiler/utils/Bag.hs
+++ b/compiler/utils/Bag.hs
@@ -30,7 +30,7 @@ import Util
import MonadUtils
import Control.Monad
import Data.Data
-import Data.List ( partition, mapAccumL )
+import Data.List ( partition, mapAccumL, foldl' )
import qualified Data.Foldable as Foldable
infixr 3 `consBag`
@@ -197,7 +197,7 @@ foldlBag :: (r -> a -> r) -> r
foldlBag _ z EmptyBag = z
foldlBag k z (UnitBag x) = k z x
foldlBag k z (TwoBags b1 b2) = foldlBag k (foldlBag k z b1) b2
-foldlBag k z (ListBag xs) = foldl k z xs
+foldlBag k z (ListBag xs) = foldl' k z xs
foldrBagM :: (Monad m) => (a -> b -> m b) -> b -> Bag a -> m b
foldrBagM _ z EmptyBag = return z
diff --git a/compiler/utils/FiniteMap.hs b/compiler/utils/FiniteMap.hs
index dccfca1..8e3139f 100644
--- a/compiler/utils/FiniteMap.hs
+++ b/compiler/utils/FiniteMap.hs
@@ -9,19 +9,20 @@ module FiniteMap (
import Data.Map (Map)
import qualified Data.Map as Map
+import Data.Foldable (foldl')
insertList :: Ord key => [(key,elt)] -> Map key elt -> Map key elt
-insertList xs m = foldl (\m (k, v) -> Map.insert k v m) m xs
+insertList xs m = foldl' (\m (k, v) -> Map.insert k v m) m xs
insertListWith :: Ord key
=> (elt -> elt -> elt)
-> [(key,elt)]
-> Map key elt
-> Map key elt
-insertListWith f xs m0 = foldl (\m (k, v) -> Map.insertWith f k v m) m0 xs
+insertListWith f xs m0 = foldl' (\m (k, v) -> Map.insertWith f k v m) m0 xs
deleteList :: Ord key => [key] -> Map key elt -> Map key elt
-deleteList ks m = foldl (flip Map.delete) m ks
+deleteList ks m = foldl' (flip Map.delete) m ks
foldRight :: (elt -> a -> a) -> a -> Map key elt -> a
foldRight = Map.fold
diff --git a/compiler/utils/OrdList.hs b/compiler/utils/OrdList.hs
index 625886d..c381b0b 100644
--- a/compiler/utils/OrdList.hs
+++ b/compiler/utils/OrdList.hs
@@ -16,6 +16,7 @@ module OrdList (
mapOL, fromOL, toOL, foldrOL, foldlOL
) where
+import Data.Foldable ( foldl' )
import Outputable
#if __GLASGOW_HASKELL__ > 710
@@ -115,7 +116,7 @@ foldlOL k z (One x) = k z x
foldlOL k z (Cons x xs) = foldlOL k (k z x) xs
foldlOL k z (Snoc xs x) = k (foldlOL k z xs) x
foldlOL k z (Two b1 b2) = foldlOL k (foldlOL k z b1) b2
-foldlOL k z (Many xs) = foldl k z xs
+foldlOL k z (Many xs) = foldl' k z xs
toOL :: [a] -> OrdList a
toOL [] = None
diff --git a/compiler/utils/UniqDFM.hs b/compiler/utils/UniqDFM.hs
index 1b3cade..4536c0f 100644
--- a/compiler/utils/UniqDFM.hs
+++ b/compiler/utils/UniqDFM.hs
@@ -58,7 +58,7 @@ import Outputable
import qualified Data.IntMap as M
import Data.Typeable
import Data.Data
-import Data.List (sortBy)
+import Data.List (sortBy, foldl')
import Data.Function (on)
import UniqFM (UniqFM, listToUFM_Directly, ufmToList, ufmToIntMap)
@@ -145,7 +145,7 @@ addToUDFM_Directly (UDFM m i) u v =
UDFM (M.insert (getKey u) (TaggedVal v i) m) (i + 1)
addListToUDFM_Directly :: UniqDFM elt -> [(Unique,elt)] -> UniqDFM elt
-addListToUDFM_Directly = foldl (\m (k, v) -> addToUDFM_Directly m k v)
+addListToUDFM_Directly = foldl' (\m (k, v) -> addToUDFM_Directly m k v)
delFromUDFM :: Uniquable key => UniqDFM elt -> key -> UniqDFM elt
delFromUDFM (UDFM m i) k = UDFM (M.delete (getKey $ getUnique k) m) i
@@ -253,7 +253,7 @@ partitionUDFM p (UDFM m i) =
-- | Delete a list of elements from a UniqDFM
delListFromUDFM :: Uniquable key => UniqDFM elt -> [key] -> UniqDFM elt
-delListFromUDFM = foldl delFromUDFM
+delListFromUDFM = foldl' delFromUDFM
-- | This allows for lossy conversion from UniqDFM to UniqFM
udfmToUfm :: UniqDFM elt -> UniqFM elt
@@ -261,7 +261,7 @@ udfmToUfm (UDFM m _i) =
listToUFM_Directly [(getUnique k, taggedFst tv) | (k, tv) <- M.toList m]
listToUDFM_Directly :: [(Unique, elt)] -> UniqDFM elt
-listToUDFM_Directly = foldl (\m (u, v) -> addToUDFM_Directly m u v) emptyUDFM
+listToUDFM_Directly = foldl' (\m (u, v) -> addToUDFM_Directly m u v) emptyUDFM
-- | Apply a function to a particular element
adjustUDFM :: Uniquable key => (elt -> elt) -> UniqDFM elt -> key -> UniqDFM elt
diff --git a/compiler/utils/UniqDSet.hs b/compiler/utils/UniqDSet.hs
index 90e9996..191b797 100644
--- a/compiler/utils/UniqDSet.hs
+++ b/compiler/utils/UniqDSet.hs
@@ -32,6 +32,7 @@ module UniqDSet (
partitionUniqDSet
) where
+import Data.Foldable (foldl')
import UniqDFM
import UniqSet
import Unique
@@ -45,13 +46,13 @@ unitUniqDSet :: Uniquable a => a -> UniqDSet a
unitUniqDSet x = unitUDFM x x
mkUniqDSet :: Uniquable a => [a] -> UniqDSet a
-mkUniqDSet = foldl addOneToUniqDSet emptyUniqDSet
+mkUniqDSet = foldl' addOneToUniqDSet emptyUniqDSet
addOneToUniqDSet :: Uniquable a => UniqDSet a -> a -> UniqDSet a
addOneToUniqDSet set x = addToUDFM set x x
addListToUniqDSet :: Uniquable a => UniqDSet a -> [a] -> UniqDSet a
-addListToUniqDSet = foldl addOneToUniqDSet
+addListToUniqDSet = foldl' addOneToUniqDSet
delOneFromUniqDSet :: Uniquable a => UniqDSet a -> a -> UniqDSet a
delOneFromUniqDSet = delFromUDFM
diff --git a/compiler/utils/UniqFM.hs b/compiler/utils/UniqFM.hs
index ed82fee..bb6eefc 100644
--- a/compiler/utils/UniqFM.hs
+++ b/compiler/utils/UniqFM.hs
@@ -79,6 +79,7 @@ import qualified Data.IntMap as M
import qualified Data.IntSet as S
import qualified Data.Foldable as Foldable
import qualified Data.Traversable as Traversable
+import Data.Foldable ( foldl' )
import Data.Typeable
import Data.Data
#if __GLASGOW_HASKELL__ > 710
@@ -231,14 +232,14 @@ emptyUFM = UFM M.empty
isNullUFM (UFM m) = M.null m
unitUFM k v = UFM (M.singleton (getKey $ getUnique k) v)
unitDirectlyUFM u v = UFM (M.singleton (getKey u) v)
-listToUFM = foldl (\m (k, v) -> addToUFM m k v) emptyUFM
-listToUFM_Directly = foldl (\m (u, v) -> addToUFM_Directly m u v) emptyUFM
-listToUFM_C f = foldl (\m (k, v) -> addToUFM_C f m k v) emptyUFM
+listToUFM = foldl' (\m (k, v) -> addToUFM m k v) emptyUFM
+listToUFM_Directly = foldl' (\m (u, v) -> addToUFM_Directly m u v) emptyUFM
+listToUFM_C f = foldl' (\m (k, v) -> addToUFM_C f m k v) emptyUFM
alterUFM f (UFM m) k = UFM (M.alter f (getKey $ getUnique k) m)
addToUFM (UFM m) k v = UFM (M.insert (getKey $ getUnique k) v m)
-addListToUFM = foldl (\m (k, v) -> addToUFM m k v)
-addListToUFM_Directly = foldl (\m (k, v) -> addToUFM_Directly m k v)
+addListToUFM = foldl' (\m (k, v) -> addToUFM m k v)
+addListToUFM_Directly = foldl' (\m (k, v) -> addToUFM_Directly m k v)
addToUFM_Directly (UFM m) u v = UFM (M.insert (getKey u) v m)
-- Arguments of combining function of M.insertWith and addToUFM_C are flipped.
@@ -246,15 +247,15 @@ addToUFM_C f (UFM m) k v =
UFM (M.insertWith (flip f) (getKey $ getUnique k) v m)
addToUFM_Acc exi new (UFM m) k v =
UFM (M.insertWith (\_new old -> exi v old) (getKey $ getUnique k) (new v) m)
-addListToUFM_C f = foldl (\m (k, v) -> addToUFM_C f m k v)
+addListToUFM_C f = foldl' (\m (k, v) -> addToUFM_C f m k v)
adjustUFM f (UFM m) k = UFM (M.adjust f (getKey $ getUnique k) m)
adjustUFM_Directly f (UFM m) u = UFM (M.adjust f (getKey u) m)
delFromUFM (UFM m) k = UFM (M.delete (getKey $ getUnique k) m)
-delListFromUFM = foldl delFromUFM
+delListFromUFM = foldl' delFromUFM
delFromUFM_Directly (UFM m) u = UFM (M.delete (getKey u) m)
-delListFromUFM_Directly = foldl delFromUFM_Directly
+delListFromUFM_Directly = foldl' delFromUFM_Directly
-- M.union is left-biased, plusUFM should be right-biased.
plusUFM (UFM x) (UFM y) = UFM (M.union y x)
diff --git a/compiler/utils/UniqSet.hs b/compiler/utils/UniqSet.hs
index a316f53..32a5a22 100644
--- a/compiler/utils/UniqSet.hs
+++ b/compiler/utils/UniqSet.hs
@@ -33,6 +33,7 @@ module UniqSet (
partitionUniqSet
) where
+import Data.Foldable ( foldl' )
import UniqFM
import Unique
@@ -93,11 +94,11 @@ type UniqSet a = UniqFM a
emptyUniqSet = emptyUFM
unitUniqSet x = unitUFM x x
-mkUniqSet = foldl addOneToUniqSet emptyUniqSet
+mkUniqSet = foldl' addOneToUniqSet emptyUniqSet
addOneToUniqSet set x = addToUFM set x x
addOneToUniqSet_C f set x = addToUFM_C f set x x
-addListToUniqSet = foldl addOneToUniqSet
+addListToUniqSet = foldl' addOneToUniqSet
delOneFromUniqSet = delFromUFM
delOneFromUniqSet_Directly = delFromUFM_Directly
diff --git a/compiler/utils/Util.hs b/compiler/utils/Util.hs
index ff0f45f..5bfde60 100644
--- a/compiler/utils/Util.hs
+++ b/compiler/utils/Util.hs
@@ -1001,7 +1001,7 @@ readRational__ r = do
readDec s = do
(ds,r) <- nonnull isDigit s
- return (foldl1 (\n d -> n * 10 + d) [ ord d - ord '0' | d <- ds ],
+ return (foldl1' (\n d -> n * 10 + d) [ ord d - ord '0' | d <- ds ],
r)
lexDecDigits = nonnull isDigit