module CoreLint (
lintCoreBindings,
lintUnfolding,
- showPass, endPass
+ showPass, endPass, endIteration
) where
#include "HsVersions.h"
\begin{code}
endPass :: DynFlags -> String -> DynFlag -> [CoreBind] -> IO [CoreBind]
-endPass dflags pass_name dump_flag binds
+endPass = dumpAndLint dumpIfSet_core
+
+endIteration :: DynFlags -> String -> DynFlag -> [CoreBind] -> IO [CoreBind]
+endIteration = dumpAndLint dumpIfSet_dyn
+
+dumpAndLint :: (DynFlags -> DynFlag -> String -> SDoc -> IO ())
+ -> DynFlags -> String -> DynFlag -> [CoreBind] -> IO [CoreBind]
+dumpAndLint dump dflags pass_name dump_flag binds
= do
-- Report result size if required
-- This has the side effect of forcing the intermediate to be evaluated
(text " Result size =" <+> int (coreBindsSize binds))
-- Report verbosely, if required
- dumpIfSet_core dflags dump_flag pass_name (pprCoreBindings binds)
+ dump dflags dump_flag pass_name (pprCoreBindings binds)
-- Type check
lintCoreBindings dflags pass_name binds
{ -- Check the pattern
-- Scrutinee type must be a tycon applicn; checked by caller
-- This code is remarkably compact considering what it does!
- -- NB: args must be in scope here so that the lintCoreArgs line works.
- -- NB: relies on existential type args coming *after* ordinary type args
-
+ -- NB: args must be in scope here so that the lintCoreArgs
+ -- line works.
+ -- NB: relies on existential type args coming *after*
+ -- ordinary type args
; con_result_ty <- lintCoreArgs con_payload_ty (varsToCoreExprs args)
; checkTys con_result_ty scrut_ty (mkBadPatMsg con_result_ty scrut_ty)
}