Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Glasgow Haskell Compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shayne Fletcher
Glasgow Haskell Compiler
Commits
65b7256a
Commit
65b7256a
authored
Feb 17, 2020
by
Ömer Sinan Ağacan
Committed by
Marge Bot
Feb 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use concatMap(M) instead of `concat . map` and the monadic variant
parent
c8439fc7
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
24 additions
and
22 deletions
+24
-22
compiler/GHC/ByteCode/Asm.hs
compiler/GHC/ByteCode/Asm.hs
+1
-1
compiler/GHC/Cmm/Switch/Implement.hs
compiler/GHC/Cmm/Switch/Implement.hs
+2
-1
compiler/GHC/CoreToByteCode.hs
compiler/GHC/CoreToByteCode.hs
+1
-1
compiler/GHC/HsToCore/PmCheck.hs
compiler/GHC/HsToCore/PmCheck.hs
+2
-1
compiler/GHC/Iface/Load.hs
compiler/GHC/Iface/Load.hs
+1
-3
compiler/GHC/Runtime/Eval.hs
compiler/GHC/Runtime/Eval.hs
+1
-1
compiler/GHC/Stg/Stats.hs
compiler/GHC/Stg/Stats.hs
+1
-1
compiler/main/DriverPipeline.hs
compiler/main/DriverPipeline.hs
+2
-2
compiler/main/HscMain.hs
compiler/main/HscMain.hs
+2
-2
compiler/nativeGen/RegAlloc/Graph/ArchBase.hs
compiler/nativeGen/RegAlloc/Graph/ArchBase.hs
+3
-1
compiler/nativeGen/RegAlloc/Liveness.hs
compiler/nativeGen/RegAlloc/Liveness.hs
+1
-1
compiler/typecheck/TcBinds.hs
compiler/typecheck/TcBinds.hs
+1
-1
compiler/typecheck/TcClassDcl.hs
compiler/typecheck/TcClassDcl.hs
+2
-2
compiler/typecheck/TcRnExports.hs
compiler/typecheck/TcRnExports.hs
+1
-1
compiler/typecheck/TcValidity.hs
compiler/typecheck/TcValidity.hs
+1
-1
compiler/utils/Digraph.hs
compiler/utils/Digraph.hs
+1
-1
compiler/utils/GraphColor.hs
compiler/utils/GraphColor.hs
+1
-1
No files found.
compiler/GHC/ByteCode/Asm.hs
View file @
65b7256a
...
@@ -101,7 +101,7 @@ assembleBCOs hsc_env proto_bcos tycons top_strs modbreaks = do
...
@@ -101,7 +101,7 @@ assembleBCOs hsc_env proto_bcos tycons top_strs modbreaks = do
return
CompiledByteCode
return
CompiledByteCode
{
bc_bcos
=
bcos'
{
bc_bcos
=
bcos'
,
bc_itbls
=
itblenv
,
bc_itbls
=
itblenv
,
bc_ffis
=
concat
(
map
protoBCOFFIs
proto_bcos
)
,
bc_ffis
=
concat
Map
protoBCOFFIs
proto_bcos
,
bc_strs
=
top_strs
++
ptrs
,
bc_strs
=
top_strs
++
ptrs
,
bc_breaks
=
modbreaks
,
bc_breaks
=
modbreaks
}
}
...
...
compiler/GHC/Cmm/Switch/Implement.hs
View file @
65b7256a
...
@@ -13,6 +13,7 @@ import GHC.Cmm.Utils
...
@@ -13,6 +13,7 @@ import GHC.Cmm.Utils
import
GHC.Cmm.Switch
import
GHC.Cmm.Switch
import
UniqSupply
import
UniqSupply
import
DynFlags
import
DynFlags
import
MonadUtils
(
concatMapM
)
--
--
-- This module replaces Switch statements as generated by the Stg -> Cmm
-- This module replaces Switch statements as generated by the Stg -> Cmm
...
@@ -35,7 +36,7 @@ cmmImplementSwitchPlans dflags g
...
@@ -35,7 +36,7 @@ cmmImplementSwitchPlans dflags g
-- Switch generation done by backend (LLVM/C)
-- Switch generation done by backend (LLVM/C)
|
targetSupportsSwitch
(
hscTarget
dflags
)
=
return
g
|
targetSupportsSwitch
(
hscTarget
dflags
)
=
return
g
|
otherwise
=
do
|
otherwise
=
do
blocks'
<-
concat
`
fmap
`
m
apM
(
visitSwitches
dflags
)
(
toBlockList
g
)
blocks'
<-
concat
M
apM
(
visitSwitches
dflags
)
(
toBlockList
g
)
return
$
ofBlockList
(
g_entry
g
)
blocks'
return
$
ofBlockList
(
g_entry
g
)
blocks'
visitSwitches
::
DynFlags
->
CmmBlock
->
UniqSM
[
CmmBlock
]
visitSwitches
::
DynFlags
->
CmmBlock
->
UniqSM
[
CmmBlock
]
...
...
compiler/GHC/CoreToByteCode.hs
View file @
65b7256a
...
@@ -1116,7 +1116,7 @@ doCase d s p (_,scrut) bndr alts is_unboxed_tuple
...
@@ -1116,7 +1116,7 @@ doCase d s p (_,scrut) bndr alts is_unboxed_tuple
binds
=
Map
.
toList
p
binds
=
Map
.
toList
p
-- NB: unboxed tuple cases bind the scrut binder to the same offset
-- NB: unboxed tuple cases bind the scrut binder to the same offset
-- as one of the alt binders, so we have to remove any duplicates here:
-- as one of the alt binders, so we have to remove any duplicates here:
rel_slots
=
nub
$
map
fromIntegral
$
concat
(
map
spread
binds
)
rel_slots
=
nub
$
map
fromIntegral
$
concat
Map
spread
binds
spread
(
id
,
offset
)
|
isFollowableArg
(
bcIdArgRep
id
)
=
[
rel_offset
]
spread
(
id
,
offset
)
|
isFollowableArg
(
bcIdArgRep
id
)
=
[
rel_offset
]
|
otherwise
=
[]
|
otherwise
=
[]
where
rel_offset
=
trunc16W
$
bytesToWords
dflags
(
d
-
offset
)
where
rel_offset
=
trunc16W
$
bytesToWords
dflags
(
d
-
offset
)
...
...
compiler/GHC/HsToCore/PmCheck.hs
View file @
65b7256a
...
@@ -59,6 +59,7 @@ import Type
...
@@ -59,6 +59,7 @@ import Type
import
GHC.HsToCore.Utils
(
isTrueLHsExpr
)
import
GHC.HsToCore.Utils
(
isTrueLHsExpr
)
import
Maybes
import
Maybes
import
qualified
GHC.LanguageExtensions
as
LangExt
import
qualified
GHC.LanguageExtensions
as
LangExt
import
MonadUtils
(
concatMapM
)
import
Control.Monad
(
when
,
forM_
,
zipWithM
)
import
Control.Monad
(
when
,
forM_
,
zipWithM
)
import
Data.List
(
elemIndex
)
import
Data.List
(
elemIndex
)
...
@@ -625,7 +626,7 @@ translateMatch _ _ (L _ (XMatch _)) = panic "translateMatch"
...
@@ -625,7 +626,7 @@ translateMatch _ _ (L _ (XMatch _)) = panic "translateMatch"
translateLGRHS
::
FamInstEnvs
->
SrcSpan
->
[
LPat
GhcTc
]
->
LGRHS
GhcTc
(
LHsExpr
GhcTc
)
->
DsM
GrdTree
translateLGRHS
::
FamInstEnvs
->
SrcSpan
->
[
LPat
GhcTc
]
->
LGRHS
GhcTc
(
LHsExpr
GhcTc
)
->
DsM
GrdTree
translateLGRHS
fam_insts
match_loc
pats
(
L
_loc
(
GRHS
_
gs
_
))
=
translateLGRHS
fam_insts
match_loc
pats
(
L
_loc
(
GRHS
_
gs
_
))
=
-- _loc apparently points to the match separator that comes after the guards..
-- _loc apparently points to the match separator that comes after the guards..
mkGrdTreeRhs
loc_sdoc
.
concat
<$>
m
apM
(
translateGuard
fam_insts
.
unLoc
)
gs
mkGrdTreeRhs
loc_sdoc
<$>
concatM
apM
(
translateGuard
fam_insts
.
unLoc
)
gs
where
where
loc_sdoc
loc_sdoc
|
null
gs
=
L
match_loc
(
sep
(
map
ppr
pats
))
|
null
gs
=
L
match_loc
(
sep
(
map
ppr
pats
))
...
...
compiler/GHC/Iface/Load.hs
View file @
65b7256a
...
@@ -751,9 +751,7 @@ loadDecls :: Bool
...
@@ -751,9 +751,7 @@ loadDecls :: Bool
->
[(
Fingerprint
,
IfaceDecl
)]
->
[(
Fingerprint
,
IfaceDecl
)]
->
IfL
[(
Name
,
TyThing
)]
->
IfL
[(
Name
,
TyThing
)]
loadDecls
ignore_prags
ver_decls
loadDecls
ignore_prags
ver_decls
=
do
{
thingss
<-
mapM
(
loadDecl
ignore_prags
)
ver_decls
=
concatMapM
(
loadDecl
ignore_prags
)
ver_decls
;
return
(
concat
thingss
)
}
loadDecl
::
Bool
-- Don't load pragmas into the decl pool
loadDecl
::
Bool
-- Don't load pragmas into the decl pool
->
(
Fingerprint
,
IfaceDecl
)
->
(
Fingerprint
,
IfaceDecl
)
...
...
compiler/GHC/Runtime/Eval.hs
View file @
65b7256a
...
@@ -1158,7 +1158,7 @@ findMatchingInstances ty = do
...
@@ -1158,7 +1158,7 @@ findMatchingInstances ty = do
ies
@
(
InstEnvs
{
ie_global
=
ie_global
,
ie_local
=
ie_local
})
<-
tcGetInstEnvs
ies
@
(
InstEnvs
{
ie_global
=
ie_global
,
ie_local
=
ie_local
})
<-
tcGetInstEnvs
let
allClasses
=
instEnvClasses
ie_global
++
instEnvClasses
ie_local
let
allClasses
=
instEnvClasses
ie_global
++
instEnvClasses
ie_local
concat
<$>
m
apM
(
\
cls
->
do
concat
M
apM
(
\
cls
->
do
let
(
matches
,
_
,
_
)
=
lookupInstEnv
True
ies
cls
[
ty
]
let
(
matches
,
_
,
_
)
=
lookupInstEnv
True
ies
cls
[
ty
]
return
matches
)
allClasses
return
matches
)
allClasses
...
...
compiler/GHC/Stg/Stats.hs
View file @
65b7256a
...
@@ -78,7 +78,7 @@ showStgStats :: [StgTopBinding] -> String
...
@@ -78,7 +78,7 @@ showStgStats :: [StgTopBinding] -> String
showStgStats
prog
showStgStats
prog
=
"STG Statistics:
\n\n
"
=
"STG Statistics:
\n\n
"
++
concat
(
map
showc
(
Map
.
toList
(
gatherStgStats
prog
)
))
++
concat
Map
showc
(
Map
.
toList
(
gatherStgStats
prog
))
where
where
showc
(
x
,
n
)
=
(
showString
(
s
x
)
.
shows
n
)
"
\n
"
showc
(
x
,
n
)
=
(
showString
(
s
x
)
.
shows
n
)
"
\n
"
...
...
compiler/main/DriverPipeline.hs
View file @
65b7256a
...
@@ -1534,7 +1534,7 @@ runPhase (RealPhase LlvmLlc) input_fn dflags
...
@@ -1534,7 +1534,7 @@ runPhase (RealPhase LlvmLlc) input_fn dflags
then
map
SysTools
.
Option
$
words
llvmOpts
then
map
SysTools
.
Option
$
words
llvmOpts
else
[]
else
[]
defaultOptions
=
map
SysTools
.
Option
.
concat
.
fm
ap
words
.
snd
defaultOptions
=
map
SysTools
.
Option
.
concat
M
ap
words
.
snd
$
unzip
(
llvmOptions
dflags
)
$
unzip
(
llvmOptions
dflags
)
...
@@ -1948,7 +1948,7 @@ linkStaticLib dflags o_files dep_packages = do
...
@@ -1948,7 +1948,7 @@ linkStaticLib dflags o_files dep_packages = do
(
when
output_exists
)
$
removeFile
full_output_fn
(
when
output_exists
)
$
removeFile
full_output_fn
pkg_cfgs
<-
getPreloadPackagesAnd
dflags
dep_packages
pkg_cfgs
<-
getPreloadPackagesAnd
dflags
dep_packages
archives
<-
concat
<$>
m
apM
(
collectArchives
dflags
)
pkg_cfgs
archives
<-
concat
M
apM
(
collectArchives
dflags
)
pkg_cfgs
ar
<-
foldl
mappend
ar
<-
foldl
mappend
<$>
(
Archive
<$>
mapM
loadObj
modules
)
<$>
(
Archive
<$>
mapM
loadObj
modules
)
...
...
compiler/main/HscMain.hs
View file @
65b7256a
...
@@ -1271,12 +1271,12 @@ markUnsafeInfer tcg_env whyUnsafe = do
...
@@ -1271,12 +1271,12 @@ markUnsafeInfer tcg_env whyUnsafe = do
(
vcat
$
pprErrMsgBagWithLoc
whyUnsafe
)
$+$
(
vcat
$
pprErrMsgBagWithLoc
whyUnsafe
)
$+$
(
vcat
$
badInsts
$
tcg_insts
tcg_env
)
(
vcat
$
badInsts
$
tcg_insts
tcg_env
)
]
]
badFlags
df
=
concat
$
m
ap
(
badFlag
df
)
unsafeFlagsForInfer
badFlags
df
=
concat
M
ap
(
badFlag
df
)
unsafeFlagsForInfer
badFlag
df
(
str
,
loc
,
on
,
_
)
badFlag
df
(
str
,
loc
,
on
,
_
)
|
on
df
=
[
mkLocMessage
SevOutput
(
loc
df
)
$
|
on
df
=
[
mkLocMessage
SevOutput
(
loc
df
)
$
text
str
<+>
text
"is not allowed in Safe Haskell"
]
text
str
<+>
text
"is not allowed in Safe Haskell"
]
|
otherwise
=
[]
|
otherwise
=
[]
badInsts
insts
=
concat
$
m
ap
badInst
insts
badInsts
insts
=
concat
M
ap
badInst
insts
checkOverlap
(
NoOverlap
_
)
=
False
checkOverlap
(
NoOverlap
_
)
=
False
checkOverlap
_
=
True
checkOverlap
_
=
True
...
...
compiler/nativeGen/RegAlloc/Graph/ArchBase.hs
View file @
65b7256a
...
@@ -21,11 +21,13 @@ module RegAlloc.Graph.ArchBase (
...
@@ -21,11 +21,13 @@ module RegAlloc.Graph.ArchBase (
bound
,
bound
,
squeese
squeese
)
where
)
where
import
GhcPrelude
import
GhcPrelude
import
UniqSet
import
UniqSet
import
UniqFM
import
UniqFM
import
Unique
import
Unique
import
MonadUtils
(
concatMapM
)
-- Some basic register classes.
-- Some basic register classes.
...
@@ -152,7 +154,7 @@ squeese regsOfClass regAlias classN countCs
...
@@ -152,7 +154,7 @@ squeese regsOfClass regAlias classN countCs
-- | powerset (for lists)
-- | powerset (for lists)
powersetL
::
[
a
]
->
[[
a
]]
powersetL
::
[
a
]
->
[[
a
]]
powersetL
=
map
concat
.
m
apM
(
\
x
->
[
[]
,[
x
]])
powersetL
=
concatM
apM
(
\
x
->
[
[]
,[
x
]])
-- | powersetLS (list of sets)
-- | powersetLS (list of sets)
...
...
compiler/nativeGen/RegAlloc/Liveness.hs
View file @
65b7256a
...
@@ -719,7 +719,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs
...
@@ -719,7 +719,7 @@ sccBlocks blocks entries mcfg = map (fmap node_payload) sccs
sccs
=
stronglyConnCompG
g2
sccs
=
stronglyConnCompG
g2
getOutEdges
::
Instruction
instr
=>
[
instr
]
->
[
BlockId
]
getOutEdges
::
Instruction
instr
=>
[
instr
]
->
[
BlockId
]
getOutEdges
instrs
=
concat
$
m
ap
jumpDestsOfInstr
instrs
getOutEdges
instrs
=
concat
M
ap
jumpDestsOfInstr
instrs
-- This is truly ugly, but I don't see a good alternative.
-- This is truly ugly, but I don't see a good alternative.
-- Digraph just has the wrong API. We want to identify nodes
-- Digraph just has the wrong API. We want to identify nodes
...
...
compiler/typecheck/TcBinds.hs
View file @
65b7256a
...
@@ -301,7 +301,7 @@ tcHsBootSigs :: [(RecFlag, LHsBinds GhcRn)] -> [LSig GhcRn] -> TcM [Id]
...
@@ -301,7 +301,7 @@ tcHsBootSigs :: [(RecFlag, LHsBinds GhcRn)] -> [LSig GhcRn] -> TcM [Id]
-- signatures in it. The renamer checked all this
-- signatures in it. The renamer checked all this
tcHsBootSigs
binds
sigs
tcHsBootSigs
binds
sigs
=
do
{
checkTc
(
null
binds
)
badBootDeclErr
=
do
{
checkTc
(
null
binds
)
badBootDeclErr
;
concat
<$>
m
apM
(
addLocM
tc_boot_sig
)
(
filter
isTypeLSig
sigs
)
}
;
concat
M
apM
(
addLocM
tc_boot_sig
)
(
filter
isTypeLSig
sigs
)
}
where
where
tc_boot_sig
(
TypeSig
_
lnames
hs_ty
)
=
mapM
f
lnames
tc_boot_sig
(
TypeSig
_
lnames
hs_ty
)
=
mapM
f
lnames
where
where
...
...
compiler/typecheck/TcClassDcl.hs
View file @
65b7256a
...
@@ -115,11 +115,11 @@ tcClassSigs :: Name -- Name of the class
...
@@ -115,11 +115,11 @@ tcClassSigs :: Name -- Name of the class
tcClassSigs
clas
sigs
def_methods
tcClassSigs
clas
sigs
def_methods
=
do
{
traceTc
"tcClassSigs 1"
(
ppr
clas
)
=
do
{
traceTc
"tcClassSigs 1"
(
ppr
clas
)
;
gen_dm_prs
<-
concat
<$>
m
apM
(
addLocM
tc_gen_sig
)
gen_sigs
;
gen_dm_prs
<-
concat
M
apM
(
addLocM
tc_gen_sig
)
gen_sigs
;
let
gen_dm_env
::
NameEnv
(
SrcSpan
,
Type
)
;
let
gen_dm_env
::
NameEnv
(
SrcSpan
,
Type
)
gen_dm_env
=
mkNameEnv
gen_dm_prs
gen_dm_env
=
mkNameEnv
gen_dm_prs
;
op_info
<-
concat
<$>
m
apM
(
addLocM
(
tc_sig
gen_dm_env
))
vanilla_sigs
;
op_info
<-
concat
M
apM
(
addLocM
(
tc_sig
gen_dm_env
))
vanilla_sigs
;
let
op_names
=
mkNameSet
[
n
|
(
n
,
_
,
_
)
<-
op_info
]
;
let
op_names
=
mkNameSet
[
n
|
(
n
,
_
,
_
)
<-
op_info
]
;
sequence_
[
failWithTc
(
badMethodErr
clas
n
)
;
sequence_
[
failWithTc
(
badMethodErr
clas
n
)
...
...
compiler/typecheck/TcRnExports.hs
View file @
65b7256a
...
@@ -256,7 +256,7 @@ exports_from_avail Nothing rdr_env _imports _this_mod
...
@@ -256,7 +256,7 @@ exports_from_avail Nothing rdr_env _imports _this_mod
exports_from_avail
(
Just
(
L
_
rdr_items
))
rdr_env
imports
this_mod
exports_from_avail
(
Just
(
L
_
rdr_items
))
rdr_env
imports
this_mod
=
do
ie_avails
<-
accumExports
do_litem
rdr_items
=
do
ie_avails
<-
accumExports
do_litem
rdr_items
let
final_exports
=
nubAvails
(
concat
(
map
snd
ie_avails
)
)
-- Combine families
let
final_exports
=
nubAvails
(
concat
Map
snd
ie_avails
)
-- Combine families
return
(
Just
ie_avails
,
final_exports
)
return
(
Just
ie_avails
,
final_exports
)
where
where
do_litem
::
ExportAccum
->
LIE
GhcPs
do_litem
::
ExportAccum
->
LIE
GhcPs
...
...
compiler/typecheck/TcValidity.hs
View file @
65b7256a
...
@@ -2838,7 +2838,7 @@ fvType (CastTy ty _) = fvType ty
...
@@ -2838,7 +2838,7 @@ fvType (CastTy ty _) = fvType ty
fvType
(
CoercionTy
{})
=
[]
fvType
(
CoercionTy
{})
=
[]
fvTypes
::
[
Type
]
->
[
TyVar
]
fvTypes
::
[
Type
]
->
[
TyVar
]
fvTypes
tys
=
concat
(
map
fvType
tys
)
fvTypes
tys
=
concat
Map
fvType
tys
sizeType
::
Type
->
Int
sizeType
::
Type
->
Int
-- Size of a type: the number of variables and constructors
-- Size of a type: the number of variables and constructors
...
...
compiler/utils/Digraph.hs
View file @
65b7256a
...
@@ -422,7 +422,7 @@ type IntGraph = G.Graph
...
@@ -422,7 +422,7 @@ type IntGraph = G.Graph
-- Data.Tree has flatten for Tree, but nothing for Forest
-- Data.Tree has flatten for Tree, but nothing for Forest
preorderF
::
Forest
a
->
[
a
]
preorderF
::
Forest
a
->
[
a
]
preorderF
ts
=
concat
(
map
flatten
ts
)
preorderF
ts
=
concat
Map
flatten
ts
{-
{-
------------------------------------------------------------
------------------------------------------------------------
...
...
compiler/utils/GraphColor.hs
View file @
65b7256a
...
@@ -324,7 +324,7 @@ selectColor colors graph u
...
@@ -324,7 +324,7 @@ selectColor colors graph u
-- the prefs of our neighbors
-- the prefs of our neighbors
colors_neighbor_prefs
colors_neighbor_prefs
=
mkUniqSet
=
mkUniqSet
$
concat
$
m
ap
nodePreference
nsConflicts
$
concat
M
ap
nodePreference
nsConflicts
-- colors that are still valid for us
-- colors that are still valid for us
colors_ok_ex
=
minusUniqSet
colors_avail
(
nodeExclusions
node
)
colors_ok_ex
=
minusUniqSet
colors_avail
(
nodeExclusions
node
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment