dump Opt_D_dump_cmmz "procpoint map" procPointMap
gs <- run $ splitAtProcPoints l callPPs procPoints procPointMap
(CmmProc h l args (stackInfo, g))
- mapM (dump Opt_D_dump_cmmz "after splitting") gs
+ mapM_ (dump Opt_D_dump_cmmz "after splitting") gs
let localCAFs = catMaybes $ map (localCAFInfo cafEnv) gs
mbpprTrace "localCAFs" (ppr localCAFs) $ return ()
gs <- liftM concat $ run $ foldM lowerSafeForeignCalls [] gs
- mapM (dump Opt_D_dump_cmmz "after lowerSafeForeignCalls") gs
+ mapM_ (dump Opt_D_dump_cmmz "after lowerSafeForeignCalls") gs
-- NO MORE GRAPH TRANSFORMATION AFTER HERE -- JUST MAKING INFOTABLES
let gs' = map (setInfoTableStackMap slotEnv areaMap) gs
- mapM (dump Opt_D_dump_cmmz "after setInfoTableStackMap") gs'
+ mapM_ (dump Opt_D_dump_cmmz "after setInfoTableStackMap") gs'
let gs'' = map (bundleCAFs cafEnv) gs'
- mapM (dump Opt_D_dump_cmmz "after bundleCAFs") gs''
+ mapM_ (dump Opt_D_dump_cmmz "after bundleCAFs") gs''
return (localCAFs, gs'')
where dflags = hsc_dflags hsc_env
mbpprTrace x y z = if dopt Opt_D_dump_cmmz dflags then pprTrace x y z else z
lintCmmExpr :: CmmExpr -> CmmLint CmmType
lintCmmExpr (CmmLoad expr rep) = do
- lintCmmExpr expr
+ _ <- lintCmmExpr expr
when (widthInBytes (typeWidth rep) >= wORD_SIZE) $
cmmCheckWordAddress expr
return rep
then return ()
else cmmLintAssignErr stmt erep reg_ty
lint (CmmStore l r) = do
- lintCmmExpr l
- lintCmmExpr r
+ _ <- lintCmmExpr l
+ _ <- lintCmmExpr r
return ()
lint (CmmCall target _res args _ _) =
lintTarget target >> mapM_ (lintCmmExpr . hintlessCmm) args
text "changed from", nest 4 (ppr old_a), text "to",
nest 4 (ppr new),
text "after supposedly reaching fixed point;",
- text "env is", pprFacts facts])
- ; setFact id a }
+ text "env is", pprFacts facts]) }
}
where pprFacts env = vcat (map pprFact (blockEnvToList env))
pprFact (id, a) = hang (ppr id <> colon) 4 (ppr a)
forw rewrite name start_facts transfers rewrites =
let anal_f :: DFM a b -> a -> Graph m l -> DFM a b
anal_f finish in' g =
- do { fwd_pure_anal name emptyBlockEnv transfers in' g; finish }
+ do { _ <- fwd_pure_anal name emptyBlockEnv transfers in' g; finish }
solve :: DFM a b -> a -> Graph m l -> Fuel -> DFM a (b, Fuel)
solve finish in_fact (Graph entry blockenv) fuel =
in_fact `seq` g `seq`
let Graph entry blockenv = g
blocks = G.postorder_dfs_from blockenv entry
- in do { solve depth name start transfers rewrites in_fact g fuel
+ in do { _ <- solve depth name start transfers rewrites in_fact g fuel
; eid <- freshBlockId "temporary entry id"
; (rewritten, fuel) <-
rew_tail (ZFirst eid) in_fact entry emptyBlockEnv fuel
; return (a, lgraphToGraph (LGraph eid rewritten), fuel)
}
don't_rewrite facts finish in_fact g fuel =
- do { solve depth name facts transfers rewrites in_fact g fuel
+ do { _ <- solve depth name facts transfers rewrites in_fact g fuel
; a <- finish
; return (a, g, fuel)
}
either_last rewrites in' (LastOther l) = fr_last rewrites l in'
check_facts in' (LastOther l) =
let LastOutFacts last_outs = ft_last_outs transfers l in'
- in mapM (uncurry checkFactMatch) last_outs
- check_facts _ LastExit = return []
+ in mapM_ (uncurry checkFactMatch) last_outs
+ check_facts _ LastExit = return ()
in fixed_pt_and_fuel
lastOutFacts :: DFM f (LastOutFacts f)
my_trace "analysis rewrites last node"
(ppr l <+> pprGraph g') $
subsolve g exit_fact fuel
- ; set_head_fact h a fuel
+ ; _ <- set_head_fact h a fuel
; return fuel }
in do { fuel <- run "backward" name set_block_fact blocks fuel
= do { code_blks <- getCgStmts the_code
; emitClosureCodeAndInfoTable cl_info [] code_blks }
where
- the_code = do { ticky_code
+ the_code = do { _ <- ticky_code
; ldvEnter (CmmReg nodeReg)
; body_code }
initHeapUsage fcode
= do { orig_hp_usage <- getHpUsage
; setHpUsage initHpUsage
- ; fixC (\heap_usage2 -> do
+ ; fixC_(\heap_usage2 -> do
{ fcode (heapHWM heap_usage2)
; getHpUsage })
; setHpUsage orig_hp_usage }
-- Ignore the label that comes back from
-- mkRetDirectTarget. It must be conjured up elswhere
- ; emitReturnTarget (idName bndr) abs_c
+ ; _ <- emitReturnTarget (idName bndr) abs_c
; return () })
; returnFC (bndr, letNoEscapeIdInfo bndr vSp lf_info) }
FCode, -- type
initC, thenC, thenFC, listCs, listFCs, mapCs, mapFCs,
- returnFC, fixC, checkedAbsC,
+ returnFC, fixC, fixC_, checkedAbsC,
stmtC, stmtsC, labelC, emitStmts, nopC, whenC, newLabelC,
newUnique, newUniqSupply,
in
result
)
+
+fixC_ :: (a -> FCode a) -> FCode ()
+fixC_ fcode = fixC fcode >> return ()
\end{code}
%************************************************************************
Allocate a chunk ON TOP OF the stack.
\begin{code}
-allocStackTop :: WordOff -> FCode VirtualSpOffset
+allocStackTop :: WordOff -> FCode ()
allocStackTop size
= do { stk_usg <- getStkUsage
; let push_virt_sp = virtSp stk_usg + size
; setStkUsage (stk_usg { virtSp = push_virt_sp,
- hwSp = hwSp stk_usg `max` push_virt_sp })
- ; return push_virt_sp }
+ hwSp = hwSp stk_usg `max` push_virt_sp }) }
\end{code}
Pop some words from the current top of stack. This is used for
de-allocating the return address in a case alternative.
\begin{code}
-deAllocStackTop :: WordOff -> FCode VirtualSpOffset
+deAllocStackTop :: WordOff -> FCode ()
deAllocStackTop size
= do { stk_usg <- getStkUsage
; let pop_virt_sp = virtSp stk_usg - size
- ; setStkUsage (stk_usg { virtSp = pop_virt_sp })
- ; return pop_virt_sp }
+ ; setStkUsage (stk_usg { virtSp = pop_virt_sp }) }
\end{code}
\begin{code}
\begin{code}
getFinalStackHW :: (VirtualSpOffset -> Code) -> Code
getFinalStackHW fcode
- = do { fixC (\hw_sp -> do
+ = do { fixC_ (\hw_sp -> do
{ fcode hw_sp
; stk_usg <- getStkUsage
; return (hwSp stk_usg) })
= do { let (bndrs, rhss) = unzip pairs
; bndrs' <- mapFCs (maybeExternaliseId dflags) bndrs
; let pairs' = zip bndrs' rhss
- ; fixC (\ new_binds -> do
+ ; fixC_(\ new_binds -> do
{ addBindsC new_binds
; mapFCs ( \ (b,e) -> cgTopRhs b e ) pairs' })
; return () }
mk_code ticky_code
= -- NB: We don't set CC when entering data (WDP 94/06)
- do { ticky_code
+ do { _ <- ticky_code
; ldvEnter (CmmReg nodeReg)
; tickyReturnOldCon (length arg_things)
; emitReturn [cmmOffsetB (CmmReg nodeReg)
; restoreCurrentCostCentre mb_cc
-- JD: We need Note: [Better Alt Heap Checks]
- ; bindArgsToRegs ret_bndrs
+ ; _ <- bindArgsToRegs ret_bndrs
; cgAlts gc_plan (NonVoid bndr) alt_type alts }
-----------------
cg_alt (con, bndrs, _uses, rhs)
= getCodeR $
maybeAltHeapCheck gc_plan $
- do { bindConArgs con base_reg bndrs
+ do { _ <- bindConArgs con base_reg bndrs
; cgExpr rhs
; return con }
FCode, -- type
initC, thenC, thenFC, listCs, listFCs, mapCs, mapFCs,
- returnFC, fixC, nopC, whenC,
+ returnFC, fixC, fixC_, nopC, whenC,
newUnique, newUniqSupply,
emit, emitData, emitProc, emitProcWithConvention, emitSimpleProc,
result
)
+fixC_ :: (a -> FCode a) -> FCode ()
+fixC_ fcode = fixC fcode >> return ()
--------------------------------------------------------
-- The code generator environment
and do Core Lint when necessary.
\begin{code}
-endPass :: DynFlags -> String -> DynFlag -> [CoreBind] -> IO [CoreBind]
+endPass :: DynFlags -> String -> DynFlag -> [CoreBind] -> IO ()
endPass = dumpAndLint dumpIfSet_core
-endPassIf :: Bool -> DynFlags -> String -> DynFlag -> [CoreBind] -> IO [CoreBind]
+endPassIf :: Bool -> DynFlags -> String -> DynFlag -> [CoreBind] -> IO ()
endPassIf cond = dumpAndLint (dumpIf_core cond)
-endIteration :: DynFlags -> String -> DynFlag -> [CoreBind] -> IO [CoreBind]
+endIteration :: DynFlags -> String -> DynFlag -> [CoreBind] -> IO ()
endIteration = dumpAndLint dumpIfSet_dyn
dumpAndLint :: (DynFlags -> DynFlag -> String -> SDoc -> IO ())
- -> DynFlags -> String -> DynFlag -> [CoreBind] -> IO [CoreBind]
+ -> DynFlags -> String -> DynFlag -> [CoreBind] -> IO ()
dumpAndLint dump dflags pass_name dump_flag binds
= do
-- Report result size if required
-- Type check
lintCoreBindings dflags pass_name binds
-
- return binds
\end{code}
lintCoreExpr (Let (Rec pairs) body)
= lintAndScopeIds bndrs $ \_ ->
- do { mapM (lintSingleBinding NotTopLevel Recursive) pairs
+ do { mapM_ (lintSingleBinding NotTopLevel Recursive) pairs
; addLoc (BodyOfLetRec bndrs) (lintCoreExpr body) }
where
bndrs = map fst pairs
else lintAndScopeId var
; scope $ \_ ->
do { -- Check the alternatives
- mapM (lintCoreAlt scrut_ty alt_ty) alts
+ mapM_ (lintCoreAlt scrut_ty alt_ty) alts
; checkCaseAlts e scrut_ty alts
; return alt_ty } }
where
| isTyVar var = lint_ty_bndr
| otherwise = lintIdBndr var linterF
where
- lint_ty_bndr = do { lintTy (tyVarKind var)
+ lint_ty_bndr = do { _ <- lintTy (tyVarKind var)
; subst <- getTvSubst
; let (subst', tv') = substTyVarBndr subst var
; updateTvSubst subst' (linterF tv') }
= do { subst <- getTvSubst
; case lookupInScope (getTvInScope subst) id of
Just v -> return v
- Nothing -> do { addErrL out_of_scope
+ Nothing -> do { _ <- addErrL out_of_scope
; return id } }
where
out_of_scope = ppr id <+> ptext (sLit "is out of scope")
let { binds_plus_cpr = do_prog binds } ;
endPass dflags "Constructed Product analysis"
Opt_D_dump_cpranal binds_plus_cpr
+ return binds_plus_cpr
}
where
do_prog :: [CoreBind] -> [CoreBind]
import Bag
import Outputable
import FastString
+
+import Control.Monad
\end{code}
-> DsM CoreExpr
dsDo stmts body _result_ty
- = go (map unLoc stmts)
+ = goL stmts
where
- go [] = dsLExpr body
-
- go (ExprStmt rhs then_expr _ : stmts)
+ goL [] = dsLExpr body
+ goL ((L loc stmt):lstmts) = putSrcSpanDs loc (go stmt lstmts)
+
+ go (ExprStmt rhs then_expr _) stmts
= do { rhs2 <- dsLExpr rhs
- ; then_expr2 <- dsExpr then_expr
- ; rest <- go stmts
+ ; case tcSplitAppTy_maybe (exprType rhs2) of
+ Just (container_ty, returning_ty) -> warnDiscardedDoBindings container_ty returning_ty
+ _ -> return ()
+ ; then_expr2 <- dsExpr then_expr
+ ; rest <- goL stmts
; return (mkApps then_expr2 [rhs2, rest]) }
- go (LetStmt binds : stmts)
- = do { rest <- go stmts
+ go (LetStmt binds) stmts
+ = do { rest <- goL stmts
; dsLocalBinds binds rest }
- go (BindStmt pat rhs bind_op fail_op : stmts)
+ go (BindStmt pat rhs bind_op fail_op) stmts
=
- do { body <- go stmts
+ do { body <- goL stmts
; rhs' <- dsLExpr rhs
; bind_op' <- dsExpr bind_op
; var <- selectSimpleMatchVarL pat
-> DsM CoreExpr
dsMDo tbl stmts body result_ty
- = go (map unLoc stmts)
+ = goL stmts
where
+ goL [] = dsLExpr body
+ goL ((L loc stmt):lstmts) = putSrcSpanDs loc (go loc stmt lstmts)
+
(m_ty, b_ty) = tcSplitAppTy result_ty -- result_ty must be of the form (m b)
mfix_id = lookupEvidence tbl mfixName
return_id = lookupEvidence tbl returnMName
fail_id = lookupEvidence tbl failMName
ctxt = MDoExpr tbl
- go [] = dsLExpr body
-
- go (LetStmt binds : stmts)
- = do { rest <- go stmts
+ go _ (LetStmt binds) stmts
+ = do { rest <- goL stmts
; dsLocalBinds binds rest }
- go (ExprStmt rhs _ rhs_ty : stmts)
+ go _ (ExprStmt rhs _ rhs_ty) stmts
= do { rhs2 <- dsLExpr rhs
- ; rest <- go stmts
+ ; warnDiscardedDoBindings m_ty rhs_ty
+ ; rest <- goL stmts
; return (mkApps (Var then_id) [Type rhs_ty, Type b_ty, rhs2, rest]) }
- go (BindStmt pat rhs _ _ : stmts)
- = do { body <- go stmts
+ go _ (BindStmt pat rhs _ _) stmts
+ = do { body <- goL stmts
; var <- selectSimpleMatchVarL pat
; match <- matchSinglePat (Var var) (StmtCtxt ctxt) pat
result_ty (cantFailMatchResult body)
; return (mkApps (Var bind_id) [Type (hsLPatType pat), Type b_ty,
rhs', Lam var match_code]) }
- go (RecStmt rec_stmts later_ids rec_ids rec_rets binds : stmts)
+ go loc (RecStmt rec_stmts later_ids rec_ids rec_rets binds) stmts
= ASSERT( length rec_ids > 0 )
ASSERT( length rec_ids == length rec_rets )
- go (new_bind_stmt : let_stmt : stmts)
+ goL (new_bind_stmt : let_stmt : stmts)
where
- new_bind_stmt = mkBindStmt (mk_tup_pat later_pats) mfix_app
- let_stmt = LetStmt (HsValBinds (ValBindsOut [(Recursive, binds)] []))
+ new_bind_stmt = L loc $ mkBindStmt (mk_tup_pat later_pats) mfix_app
+ let_stmt = L loc $ LetStmt (HsValBinds (ValBindsOut [(Recursive, binds)] []))
-- Remove the later_ids that appear (without fancy coercions)
mk_ret_tup [r] = r
mk_ret_tup rs = noLoc $ ExplicitTuple rs Boxed
\end{code}
+
+
+%************************************************************************
+%* *
+\subsection{Errors and contexts}
+%* *
+%************************************************************************
+
+\begin{code}
+-- Warn about certain types of values discarded in monadic bindings (#3263)
+warnDiscardedDoBindings :: Type -> Type -> DsM ()
+warnDiscardedDoBindings container_ty returning_ty = do
+ -- Warn about discarding non-() things in 'monadic' binding
+ warn_unused <- doptDs Opt_WarnUnusedDoBind
+ when (warn_unused && not (returning_ty `tcEqType` unitTy)) $
+ warnDs (unusedMonadBind returning_ty)
+
+ -- Warn about discarding m a things in 'monadic' binding of the same type
+ warn_wrong <- doptDs Opt_WarnWrongDoBind
+ case tcSplitAppTy_maybe returning_ty of
+ Just (returning_container_ty, _) -> when (warn_wrong && container_ty `tcEqType` returning_container_ty) $
+ warnDs (wrongMonadBind returning_ty)
+ _ -> return ()
+
+unusedMonadBind :: Type -> SDoc
+unusedMonadBind returning_ty
+ = ptext (sLit "A do-notation statement threw away a result of a type which appears to contain something other than (), namely") <+> ppr returning_ty <>
+ ptext (sLit ". You can suppress this warning by explicitly binding the result to _")
+
+wrongMonadBind :: Type -> SDoc
+wrongMonadBind returning_ty
+ = ptext (sLit "A do-notation statement threw away a result of a type that like a monadic action waiting to execute, namely") <+> ppr returning_ty <>
+ ptext (sLit ". You can suppress this warning by explicitly binding the result to _")
+\end{code}
-- with the changed error handling and logging?
let noop_log _ _ _ _ = return ()
expr = "show " ++ showSDoc (ppr bname)
- GHC.setSessionDynFlags dflags{log_action=noop_log}
+ _ <- GHC.setSessionDynFlags dflags{log_action=noop_log}
txt_ <- withExtendedLinkEnv [(bname, val)]
(GHC.compileExpr expr)
let myprec = 10 -- application precedence. TODO Infix constructors
pls1 = pls { objs_loaded = objs_loaded' }
unlinkeds = concatMap linkableUnlinked new_objs
- mapM loadObj (map nameOfObject unlinkeds)
+ mapM_ loadObj (map nameOfObject unlinkeds)
-- Link the all together
ok <- resolveObjs
(ty_tvs, _, _) <- tcInstType return ty
(ty_tvs', _, ty') <- tcInstType (mapM tcInstTyVar) ty
(_, _, rtti_ty') <- tcInstType (mapM tcInstTyVar) (sigmaType rtti_ty)
- getLIE(boxyUnify rtti_ty' ty')
+ _ <- getLIE(boxyUnify rtti_ty' ty')
tvs1_contents <- zonkTcTyVars ty_tvs'
let subst = (uncurry zipTopTvSubst . unzip)
[(tv,ty) | (tv,ty) <- zip ty_tvs tvs1_contents
text " in presence of newtype evidence " <> ppr new_tycon)
vars <- mapM (newVar . tyVarKind) (tyConTyVars new_tycon)
let ty' = mkTyConApp new_tycon vars
- liftTcM (boxyUnify ty (repType ty'))
+ _ <- liftTcM (boxyUnify ty (repType ty'))
-- assumes that reptype doesn't ^^^^ touch tyconApp args
return ty'
initCvt :: SrcSpan -> CvtM a -> Either Message a
initCvt loc (CvtM m) = m loc
-force :: a -> CvtM a
-force a = a `seq` return a
+force :: a -> CvtM ()
+force a = a `seq` return ()
failWith :: Message -> CvtM a
failWith m = CvtM (\_ -> Left full_msg)
cvtName :: OccName.NameSpace -> TH.Name -> CvtM RdrName
cvtName ctxt_ns (TH.Name occ flavour)
| not (okOcc ctxt_ns occ_str) = failWith (badOcc ctxt_ns occ_str)
- | otherwise = force (thRdrName ctxt_ns occ_str flavour)
+ | otherwise = force rdr_name >> return rdr_name
where
occ_str = TH.occString occ
+ rdr_name = thRdrName ctxt_ns occ_str flavour
okOcc :: OccName.NameSpace -> String -> Bool
okOcc _ [] = False
-- The version and way descriptor go next
put_ bh (show opt_HiVersion)
way_descr <- getWayDescr
- put bh way_descr
+ put_ bh way_descr
-- Remember where the symbol table pointer will go
symtab_p_p <- tellBin bh
instance Binary DmdType where
-- Ignore DmdEnv when spitting out the DmdType
- put bh (DmdType _ ds dr) = do p <- put bh ds; put bh dr; return (castBin p)
+ put bh (DmdType _ ds dr) = do p <- put bh ds; put_ bh dr; return (castBin p)
get bh = do ds <- get bh; dr <- get bh; return (DmdType emptyVarEnv ds dr)
instance Binary Demand where
loadWiredInHomeIface :: Name -> IfM lcl ()
loadWiredInHomeIface name
= ASSERT( isWiredInName name )
- do loadSysInterface doc (nameModule name); return ()
+ do _ <- loadSysInterface doc (nameModule name); return ()
where
doc = ptext (sLit "Need home interface for wired-in thing") <+> ppr name
-- and complaining about cycles
hsc_env <- getSession
root <- liftIO getCurrentDirectory
- mapM (liftIO . processDeps dflags hsc_env excl_mods root (mkd_tmp_hdl files)) sorted
+ mapM_ (liftIO . processDeps dflags hsc_env excl_mods root (mkd_tmp_hdl files)) sorted
-- If -ddump-mod-cycles, show cycles in the module graph
liftIO $ dumpModCycles dflags mod_summaries
-> return ([], ms_hs_date summary)
-- We're in --make mode: finish the compilation pipeline.
_other
- -> do runPipeline StopLn hsc_env' (output_fn,Nothing)
+ -> do _ <- runPipeline StopLn hsc_env' (output_fn,Nothing)
(Just basename)
Persistent
(Just location)
let (stub_c,_,stub_o) = mkStubPaths (hsc_dflags hsc_env)
(moduleName mod) location
- runPipeline StopLn hsc_env (stub_c,Nothing) Nothing
+ _ <- runPipeline StopLn hsc_env (stub_c,Nothing) Nothing
(SpecificFile stub_o) Nothing{-no ModLocation-}
return stub_o
pvm_executable_base = "=" ++ input_fn
pvm_executable = pvm_root ++ "/bin/" ++ pvm_arch ++ "/" ++ pvm_executable_base
-- nuke old binary; maybe use configur'ed names for cp and rm?
- tryIO (removeFile pvm_executable)
+ _ <- tryIO (removeFile pvm_executable)
-- move the newly created binary into PVM land
copy dflags "copying PVM executable" input_fn pvm_executable
-- generate a wrapper script for running a parallel prg under PVM
-
-- |
-- Dynamic flags
--
| Opt_WarnUnrecognisedPragmas
| Opt_WarnDodgyForeignImports
| Opt_WarnLazyUnliftedBindings
+ | Opt_WarnUnusedDoBind
+ | Opt_WarnWrongDoBind
+
-- language opts
| Opt_OverlappingInstances
Opt_WarnMissingMethods,
Opt_WarnDuplicateExports,
Opt_WarnLazyUnliftedBindings,
- Opt_WarnDodgyForeignImports
+ Opt_WarnDodgyForeignImports,
+ Opt_WarnWrongDoBind
]
minusWOpts :: [DynFlag]
Opt_WarnNameShadowing,
Opt_WarnMissingSigs,
Opt_WarnHiShadows,
- Opt_WarnOrphans
+ Opt_WarnOrphans,
+ Opt_WarnUnusedDoBind
]
-- minuswRemovesOpts should be every warning option
( "warn-unrecognised-pragmas", Opt_WarnUnrecognisedPragmas, const Supported ),
( "warn-lazy-unlifted-bindings", Opt_WarnLazyUnliftedBindings,
const $ Deprecated "lazy unlifted bindings will be an error in GHC 6.14, and this flag will no longer exist"),
+ ( "warn-unused-do-bind", Opt_WarnUnusedDoBind, const Supported ),
+ ( "warn-wrong-do-bind", Opt_WarnWrongDoBind, const Supported ),
( "print-explicit-foralls", Opt_PrintExplicitForalls, const Supported ),
( "strictness", Opt_Strictness, const Supported ),
( "static-argument-transformation", Opt_StaticArgumentTransformation, const Supported ),
(flattenSCCs mg2_with_srcimps)
stable_mods
- liftIO $ evaluate pruned_hpt
+ _ <- liftIO $ evaluate pruned_hpt
-- before we unload anything, make sure we don't leave an old
-- interactive context around pointing to dead bindings. Also,
(iface, changed, _details, cgguts)
<- hscNormalIface guts Nothing
hscWriteIface iface changed modSummary
- hscGenHardCode cgguts modSummary
+ _ <- hscGenHardCode cgguts modSummary
return ()
-- Makes a "vanilla" ModGuts.
-- First, set the target to the desired filename
target <- guessTarget fn Nothing
addTarget target
- load LoadAllTargets
+ _ <- load LoadAllTargets
-- Then find dependencies
modGraph <- depanal [] True
case find ((== fn) . msHsFilePath) modGraph of
parseCmmFile dflags filename
cmms <- liftIO $ optionallyConvertAndOrCPS hsc_env [cmm]
rawCmms <- liftIO $ cmmToRawCmm cmms
- liftIO $ codeOutput dflags no_mod no_loc NoStubs [] rawCmms
+ _ <- liftIO $ codeOutput dflags no_mod no_loc NoStubs [] rawCmms
return ()
where
no_mod = panic "hscCmmFile: no_mod"
let history' = mkHistory hsc_env apStack info `consBL` history
-- probably better make history strict here, otherwise
-- our BoundedList will be pointless.
- liftIO $ evaluate history'
+ _ <- liftIO $ evaluate history'
status <-
withBreakAction True (hsc_dflags hsc_env)
breakMVar statusMVar $ do
-- and run a loop piping the output from the compiler to the log_action in DynFlags
hSetBuffering hStdOut LineBuffering
hSetBuffering hStdErr LineBuffering
- forkIO (readerProc chan hStdOut filter_fn)
- forkIO (readerProc chan hStdErr filter_fn)
+ _ <- forkIO (readerProc chan hStdOut filter_fn)
+ _ <- forkIO (readerProc chan hStdErr filter_fn)
-- we don't want to finish until 2 streams have been completed
-- (stdout and stderr)
-- nor until 1 exit code has been retrieved.
rnBracket (VarBr n) = do { name <- lookupOccRn n
; this_mod <- getModule
; checkM (nameIsLocalOrFrom this_mod name) $ -- Reason: deprecation checking asumes the
- do { loadInterfaceForName msg name -- home interface is loaded, and this is the
+ do { _ <- loadInterfaceForName msg name -- home interface is loaded, and this is the
; return () } -- only way that is going to happen
; return (VarBr name, unitFV name) }
where
let (bndrs', dups) = removeDups cmpByOcc bndrs
inner_env = extendLocalRdrEnv orig_lcl_env bndrs'
- mapM dupErr dups
+ mapM_ dupErr dups
(thing, fvs) <- setLocalRdrEnv inner_env thing_inside
return (([], thing), fvs)
lintStgExpr (StgSCC _ expr) = lintStgExpr expr
lintStgExpr e@(StgCase scrut _ _ bndr _ alts_type alts) = runMaybeT $ do
- MaybeT $ lintStgExpr scrut
+ _ <- MaybeT $ lintStgExpr scrut
MaybeT $ liftM Just $
case alts_type of
-- Post-condition: the returned Insts are full zonked
unifyCtxts [] = panic "unifyCtxts []"
unifyCtxts (sig1 : sigs) -- Argument is always non-empty
- = do { mapM unify_ctxt sigs
+ = do { mapM_ unify_ctxt sigs
; theta <- zonkTcThetaType (sig_theta sig1)
; newDictBndrs (sig_loc sig1) theta }
where
checkDistinctTyVars sig_tvs
= do { zonked_tvs <- mapM zonkSigTyVar sig_tvs
- ; foldlM check_dup emptyVarEnv (sig_tvs `zip` zonked_tvs)
+ ; foldlM_ check_dup emptyVarEnv (sig_tvs `zip` zonked_tvs)
; return zonked_tvs }
where
check_dup :: TyVarEnv TcTyVar -> (TcTyVar, TcTyVar) -> TcM (TyVarEnv TcTyVar)
group `lengthExceeds` 1]
get_uniq (tc,_) = getUnique tc
- mapM (addErrTc . dupGenericInsts) bad_groups
+ mapM_ (addErrTc . dupGenericInsts) bad_groups
-- Check that there is an InstInfo for each generic type constructor
let
, isLiftedTypeKind res -- Horrible hack to make less use
= return (mkTyConApp tup_tc []) -- of mkAnyPrimTyCon
| otherwise
- = do { warn (getSrcSpan tv) msg
+ = do { _ <- warn (getSrcSpan tv) msg
; return (mkTyConApp (mkAnyPrimTyCon (getUnique tv) kind) []) }
-- Same name as the tyvar, apart from making it start with a colon (sigh)
-- I dread to think what will happen if this gets out into an
tcPatBndr (PS { pat_ctxt = LetPat lookup_sig }) bndr_name pat_ty
| Just mono_ty <- lookup_sig bndr_name
= do { mono_name <- newLocalName bndr_name
- ; boxyUnify mono_ty pat_ty
+ ; _ <- boxyUnify mono_ty pat_ty
; return (Id.mkLocalId mono_name mono_ty) }
| otherwise
return ty'
else do -- OpenTypeKind, so constrain it
{ ty2 <- newFlexiTyVarTy argTypeKind
- ; unifyType ty' ty2
+ ; _ <- unifyType ty' ty2
; return ty' }}
where
msg = pp_this <+> ptext (sLit "cannot be bound to an unboxed tuple")
-- Check that the pattern has a lifted type
; pat_tv <- newBoxyTyVar liftedTypeKind
- ; boxyUnify pat_ty (mkTyVarTy pat_tv)
+ ; _ <- boxyUnify pat_ty (mkTyVarTy pat_tv)
; return (LazyPat pat', [], res) }
\begin{code}
tcSimplifyBracket :: [Inst] -> TcM ()
tcSimplifyBracket wanteds
- = do { tryHardCheckLoop doc wanteds
+ = do { _ <- tryHardCheckLoop doc wanteds
; return () }
where
doc = text "tcSimplifyBracket"
= do { mb_chosen_ty <- try_default default_tys
; case mb_chosen_ty of
Nothing -> return ()
- Just chosen_ty -> do { unifyType chosen_ty (mkTyVarTy tyvar)
+ Just chosen_ty -> do { _ <- unifyType chosen_ty (mkTyVarTy tyvar)
; warnDefault dicts chosen_ty } }
where
(_,_,tyvar) = ASSERT(not (null dicts)) head dicts -- Should be non-empty
; tcSimplifyBracket lie
-- Make the expected type have the right shape
- ; boxyUnify meta_ty res_ty
+ ; _ <- boxyUnify meta_ty res_ty
-- Return the original expression, not the type-decorated one
; pendings <- readMutVar pending_splices
tc_bracket _ (ExpBr expr)
= do { any_ty <- newFlexiTyVarTy liftedTypeKind
- ; tcMonoExprNC expr any_ty -- NC for no context; tcBracket does that
+ ; _ <- tcMonoExprNC expr any_ty -- NC for no context; tcBracket does that
; tcMetaTy expQTyConName }
-- Result type is Expr (= Q Exp)
tc_bracket _ (TypBr typ)
- = do { tcHsSigTypeNC ThBrackCtxt typ
+ = do { _ <- tcHsSigTypeNC ThBrackCtxt typ
; tcMetaTy typeQTyConName }
-- Result type is Type (= Q Typ)
tc_bracket _ (DecBr decls)
- = do { tcTopSrcDecls emptyModDetails decls
+ = do { _ <- tcTopSrcDecls emptyModDetails decls
-- Typecheck the declarations, dicarding the result
-- We'll get all that stuff later, when we splice it in
-- Here (h 4) :: Q Exp
-- but $(h 4) :: forall a.a i.e. anything!
- unBox res_ty
+ _ <- unBox res_ty
meta_exp_ty <- tcMetaTy expQTyConName
expr' <- setStage (Splice next_level) (
setLIEVar lie_var $
unifyTypeList :: [TcTauType] -> TcM ()
unifyTypeList [] = return ()
unifyTypeList [_] = return ()
-unifyTypeList (ty1:tys@(ty2:_)) = do { unifyType ty1 ty2
- ; unifyTypeList tys }
+unifyTypeList (ty1:tys@(ty2:_)) = do { _ <- unifyType ty1 ty2
+ ; unifyTypeList tys }
\end{code}
%************************************************************************
-- with that type.
zapToMonotype res_ty
= do { res_tau <- newFlexiTyVarTy liftedTypeKind
- ; boxyUnify res_tau res_ty
+ ; _ <- boxyUnify res_tau res_ty
; return res_tau }
unBox :: BoxyType -> TcM TcType
-- define one of put_, put. Use of put_ is recommended because it
-- is more likely that tail-calls can kick in, and we rarely need the
-- position return value.
- put_ bh a = do put bh a; return ()
+ put_ bh a = do _ <- put bh a; return ()
put bh a = do p <- tellBin bh; put_ bh a; return p
putAt :: Binary a => BinHandle -> Bin a -> a -> IO ()
-putAt bh p x = do seekBin bh p; put bh x; return ()
+putAt bh p x = do seekBin bh p; put_ bh x; return ()
getAt :: Binary a => BinHandle -> Bin a -> IO a
getAt bh p = do seekBin bh p; get bh
gblock (do
a <- before
r <- gunblock (thing a) `gonException` after a
- after a
+ _ <- after a
return r)
a `gfinally` sequel =
gblock (do
r <- gunblock a `gonException` sequel
- sequel
+ _ <- sequel
return r)
instance ExceptionMonad IO where
-- second argument is executed and the exception is raised again.
gonException :: (ExceptionMonad m) => m a -> m b -> m a
gonException ioA cleanup = ioA `gcatch` \e ->
- do cleanup
+ do _ <- cleanup
throw (e :: SomeException)
unIOEnv (f r) env })
thenM_ :: IOEnv env a -> IOEnv env b -> IOEnv env b
-thenM_ (IOEnv m) f = IOEnv (\ env -> do { m env ; unIOEnv f env })
+thenM_ (IOEnv m) f = IOEnv (\ env -> do { _ <- m env ; unIOEnv f env })
failM :: IOEnv env a
failM = IOEnv (\ _ -> throwIO IOEnvFailure)
, concatMapM
, mapMaybeM
, anyM, allM
- , foldlM, foldrM
+ , foldlM, foldlM_, foldrM
, maybeMapM
) where
foldlM :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m a
foldlM = foldM
+-- | Monadic version of foldl that discards its result
+foldlM_ :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m ()
+foldlM_ = foldM_
+
-- | Monadic version of foldr
foldrM :: (Monad m) => (b -> a -> m a) -> a -> [b] -> m a
foldrM _ z [] = return z
(thread:_) -> throwTo thread interrupt_exn
--
#if !defined(mingw32_HOST_OS)
- installHandler sigQUIT (Catch interrupt) Nothing
- installHandler sigINT (Catch interrupt) Nothing
+ _ <- installHandler sigQUIT (Catch interrupt) Nothing
+ _ <- installHandler sigINT (Catch interrupt) Nothing
return ()
#else
-- GHC 6.3+ has support for console events on Windows
<entry><option>-fno-warn-unused-matches</option></entry>
</row>
+ <row>
+ <entry><option>-fwarn-unused-do-bind</option></entry>
+ <entry>warn about do bindings that appear to throw away values of types other than <literal>()</literal></entry>
+ <entry>dynamic</entry>
+ <entry><option>-fno-warn-unused-do-bind</option></entry>
+ </row>
+
+ <row>
+ <entry><option>-fwarn-wrong-do-bind</option></entry>
+ <entry>warn about do bindings that appear to throw away monadic values that you should have bound instead</entry>
+ <entry>dynamic</entry>
+ <entry><option>-fno-warn-wrong-do-bind</option></entry>
+ </row>
+
</tbody>
</tgroup>
</informaltable>
<option>-fwarn-duplicate-exports</option>,
<option>-fwarn-missing-fields</option>,
<option>-fwarn-missing-methods</option>,
- <option>-fwarn-lazy-unlifted-bindings</option>, and
+ <option>-fwarn-lazy-unlifted-bindings</option>,
+ <option>-fwarn-wrong-do-bind</option>, and
<option>-fwarn-dodgy-foreign-imports</option>. The following
flags are
simple ways to select standard “packages” of warnings:
<option>-fwarn-simple-patterns</option>,
<option>-fwarn-tabs</option>,
<option>-fwarn-incomplete-record-updates</option>,
- <option>-fwarn-monomorphism-restriction</option>, and
+ <option>-fwarn-monomorphism-restriction</option>,
+ <option>-fwarn-unused-do-bind</option>, and
<option>-fwarn-implicit-prelude</option>.</para>
</listitem>
</varlistentry>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-fwarn-unused-do-bind</option>:</term>
+ <listitem>
+ <indexterm><primary><option>-fwarn-unused-do-bind</option></primary></indexterm>
+ <indexterm><primary>unused do binding, warning</primary></indexterm>
+ <indexterm><primary>do binding, unused</primary></indexterm>
+
+ <para>Report expressions occuring in <literal>do</literal> and <literal>mdo</literal> blocks
+ that appear to silently throw information away.
+ For instance <literal>do { mapM popInt xs ; return 10 }</literal> would report
+ the first statement in the <literal>do</literal> block as suspicious,
+ as it has the type <literal>StackM [Int]</literal> and not <literal>StackM ()</literal>, but that
+ <literal>[Int]</literal> value is not bound to anything. The warning is suppressed by
+ explicitly mentioning in the source code that your program is throwing something away:
+ <programlisting>
+ do { _ <- mapM popInt xs ; return 10 }
+ </programlisting>
+ Of course, in this particular situation you can do even better:
+ <programlisting>
+ do { mapM_ popInt xs ; return 10 }
+ </programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>-fwarn-wrong-do-bind</option>:</term>
+ <listitem>
+ <indexterm><primary><option>-fwarn-wrong-do-bind</option></primary></indexterm>
+ <indexterm><primary>apparently erroneous do binding, warning</primary></indexterm>
+ <indexterm><primary>do binding, apparently erroneous</primary></indexterm>
+
+ <para>Report expressions occuring in <literal>do</literal> and <literal>mdo</literal> blocks
+ that appear to lack a binding.
+ For instance <literal>do { return (popInt 10) ; return 10 }</literal> would report
+ the first statement in the <literal>do</literal> block as suspicious,
+ as it has the type <literal>StackM (StackM Int)</literal> (which consists of two nested applications
+ of the same monad constructor), but which is not then "unpacked" by binding the result.
+ The warning is suppressed by explicitly mentioning in the source code that your program is throwing something away:
+ <programlisting>
+ do { _ <- return (popInt 10) ; return 10 }
+ </programlisting>
+ For almost all sensible programs this will indicate a bug, and you probably intended to write:
+ <programlisting>
+ do { popInt 10 ; return 10 }
+ </programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
<para>If you're feeling really paranoid, the
setLogAction = do
encoder <- getEncoder
dflags <- GHC.getSessionDynFlags
- GHC.setSessionDynFlags dflags {log_action = logAction encoder}
+ _ <- GHC.setSessionDynFlags dflags {log_action = logAction encoder}
return ()
where
logAction encoder severity srcSpan style msg = case severity of
let f ref (Just ptr) = writeIORef ref ptr
f _ Nothing = panic "interactiveUI:setBuffering2"
- zipWithM f [stdin_ptr,stdout_ptr,stderr_ptr]
- [mb_stdin_ptr,mb_stdout_ptr,mb_stderr_ptr]
- return ()
+ zipWithM_ f [stdin_ptr,stdout_ptr,stderr_ptr]
+ [mb_stdin_ptr,mb_stdout_ptr,mb_stderr_ptr]
flushInterpBuffers :: GHCi ()
flushInterpBuffers
-- it refers to might be finalized, including the standard Handles.
-- This sounds like a bug, but we don't have a good solution right
-- now.
- liftIO $ newStablePtr stdin
- liftIO $ newStablePtr stdout
- liftIO $ newStablePtr stderr
+ _ <- liftIO $ newStablePtr stdin
+ _ <- liftIO $ newStablePtr stdout
+ _ <- liftIO $ newStablePtr stderr
-- Initialise buffering for the *interpreted* I/O system
initInterpBuffering
-- QUESTION: is userError the one to use here?
collectError = userError "unterminated multiline command :{ .. :}"
doCommand (':' : cmd) = specialCommand cmd
- doCommand stmt = do timeIt $ lift $ runStmt stmt GHC.RunToCompletion
+ doCommand stmt = do _ <- timeIt $ lift $ runStmt stmt GHC.RunToCompletion
return False
enqueueCommands :: [String] -> GHCi ()
-- are really two stdin Handles. So we flush any bufferred data in
-- GHCi's stdin Handle here (only relevant if stdin is attached to
-- a file, otherwise the read buffer can't be flushed).
- liftIO $ IO.try $ hFlushAll stdin
+ _ <- liftIO $ IO.try $ hFlushAll stdin
#endif
result <- GhciMonad.runStmt stmt step
afterRunStmt (const True) result
outputStr "Warning: changing directory causes all loaded modules to be unloaded,\nbecause the search path has changed.\n"
prev_context <- GHC.getContext
GHC.setTargets []
- GHC.load LoadAllTargets
+ _ <- GHC.load LoadAllTargets
lift $ setContextAfterLoad prev_context False []
GHC.workingDirectoryChanged
dir <- expandPath dir
let cmd = editor st
when (null cmd)
$ ghcError (CmdLineError "editor not set, use :set editor")
- io $ system (cmd ++ ' ':file)
+ _ <- io $ system (cmd ++ ' ':file)
return ()
-- The user didn't specify a file so we pick one for them.
loadModule fs = timeIt (loadModule' fs)
loadModule_ :: [FilePath] -> InputT GHCi ()
-loadModule_ fs = do loadModule (zip fs (repeat Nothing)); return ()
+loadModule_ fs = loadModule (zip fs (repeat Nothing)) >> return ()
loadModule' :: [(FilePath, Maybe Phase)] -> InputT GHCi SuccessFlag
loadModule' files = do
prev_context <- GHC.getContext
-- unload first
- GHC.abandonAll
+ _ <- GHC.abandonAll
lift discardActiveBreakPoints
GHC.setTargets []
- GHC.load LoadAllTargets
+ _ <- GHC.load LoadAllTargets
let (filenames, phases) = unzip files
exp_filenames <- mapM expandPath filenames
reloadModule :: String -> InputT GHCi ()
reloadModule m = do
prev_context <- GHC.getContext
- doLoad True prev_context $
+ _ <- doLoad True prev_context $
if null m then LoadAllTargets
else LoadUpTo (GHC.mkModuleName m)
return ()
when (packageFlags dflags /= pkg_flags) $ do
io $ hPutStrLn stderr "package flags have changed, resetting and loading new packages..."
GHC.setTargets []
- GHC.load LoadAllTargets
+ _ <- GHC.load LoadAllTargets
io (linkPackages dflags new_pkgs)
-- package flags changed, we can't re-use any of the old context
setContextAfterLoad ([],[]) False []
stepCmd :: String -> GHCi ()
stepCmd [] = doContinue (const True) GHC.SingleStep
-stepCmd expression = do runStmt expression GHC.SingleStep; return ()
+stepCmd expression = runStmt expression GHC.SingleStep >> return ()
stepLocalCmd :: String -> GHCi ()
stepLocalCmd [] = do
traceCmd :: String -> GHCi ()
traceCmd [] = doContinue (const True) GHC.RunAndLogSteps
-traceCmd expression = do runStmt expression GHC.RunAndLogSteps; return ()
+traceCmd expression = runStmt expression GHC.RunAndLogSteps >> return ()
continueCmd :: String -> GHCi ()
continueCmd = noArgs $ doContinue (const True) GHC.RunToCompletion
doContinue :: (SrcSpan -> Bool) -> SingleStep -> GHCi ()
doContinue pred step = do
runResult <- resume pred step
- afterRunStmt pred runResult
+ _ <- afterRunStmt pred runResult
return ()
abandonCmd :: String -> GHCi ()
discardActiveBreakPoints :: GHCi ()
discardActiveBreakPoints = do
st <- getGHCiState
- mapM (turnOffBreak.snd) (breaks st)
+ mapM_ (turnOffBreak.snd) (breaks st)
setGHCiState $ st { breaks = [] }
deleteBreak :: Int -> GHCi ()
then printForUser (text "Breakpoint" <+> ppr identity <+>
text "does not exist")
else do
- mapM (turnOffBreak.snd) this
+ mapM_ (turnOffBreak.snd) this
setGHCiState $ st { breaks = rest }
turnOffBreak :: BreakLocation -> GHCi Bool
liftIO $ showBanner cli_mode dflags2
-- we've finished manipulating the DynFlags, update the session
- GHC.setSessionDynFlags dflags2
+ _ <- GHC.setSessionDynFlags dflags2
dflags3 <- GHC.getSessionDynFlags
hsc_env <- GHC.getSession
parse
+++
(do n <- parse
- string "-*"
+ _ <- string "-*"
return (PackageIdentifier{ pkgName = n, pkgVersion = globVersion }))
-- globVersion means "all versions"
| otherwise
= do str <- readFile filename
let packages = map convertPackageInfoIn $ read str
- Exception.evaluate packages
+ _ <- Exception.evaluate packages
`catchError` \e->
die ("error while parsing " ++ filename ++ ": " ++ show e)
return (filename,packages)
else do
when (not simple_output) $ do
reportError ("There are problems in package " ++ display (package p) ++ ":")
- reportValidateErrors es " " Nothing
+ _ <- reportValidateErrors es " " Nothing
return ()
return [p]
(Exception.ErrorCall "interrupted")
--
#if !defined(mingw32_HOST_OS)
- installHandler sigQUIT (Catch interrupt) Nothing
- installHandler sigINT (Catch interrupt) Nothing
+ _ <- installHandler sigQUIT (Catch interrupt) Nothing
+ _ <- installHandler sigINT (Catch interrupt) Nothing
return ()
#elif __GLASGOW_HASKELL__ >= 603
-- GHC 6.3+ has support for console events on Windows
case getOpt Permute (options plugin []) args of
(_,_,errs) | not (null errs)
-> do putStrLn "hpc failed:"
- sequence [ putStr (" " ++ err)
+ sequence_ [ putStr (" " ++ err)
| err <- errs
]
putStrLn $ "\n"