The Desugarer: turning HsSyn into Core.
\begin{code}
-{-# OPTIONS -w #-}
--- The above warning supression flag is a temporary kludge.
--- While working on this module you are encouraged to remove it and fix
--- any warnings in the module. See
--- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
--- for details
-
module Desugar ( deSugar, deSugarExpr ) where
#include "HsVersions.h"
import DsExpr () -- Forces DsExpr to be compiled; DsBinds only
-- depends on DsExpr.hi-boot.
import Module
-import UniqFM
-import PackageConfig
import RdrName
import NameSet
import VarSet
import CoreLint
import CoreFVs
import ErrUtils
-import ListSetOps
import Outputable
import SrcLoc
import Maybes
import FastString
-import Util
+import Pretty ( Doc )
import Coverage
import IOEnv
import Data.IORef
tcg_type_env = type_env,
tcg_imports = imports,
tcg_exports = exports,
- tcg_inst_uses = dfun_uses_var,
- tcg_th_used = th_var,
tcg_keep = keep_var,
tcg_rdr_env = rdr_env,
tcg_fix_env = fix_env,
{ core_prs <- dsTopLHsBinds auto_scc binds_cvr
; (ds_fords, foreign_prs) <- dsForeigns fords
; let all_prs = foreign_prs ++ core_prs
- local_bndrs = mkVarSet (map fst all_prs)
- ; ds_rules <- mappM (dsRule mod local_bndrs) rules
+ ; ds_rules <- mappM dsRule rules
; return (all_prs, catMaybes ds_rules, ds_fords, ds_hpc_info, modBreaks)
}
; case mb_res of {
| not opt_SccProfilingOn -- No profiling
= NoSccs
| opt_AutoSccsOnAllToplevs -- Add auto-scc on all top-level things
- = AddSccs mod (\id -> True)
+ = AddSccs mod (\_ -> True)
| opt_AutoSccsOnExportedToplevs -- Only on exported things
= AddSccs mod (\id -> idName id `elemNameSet` exports)
| otherwise
-- it's just because the type checker is rather busy already and
-- I didn't want to pass in yet another mapping.
+addExportFlags :: HscTarget -> NameSet -> NameSet -> [(Id, t)] -> [CoreRule]
+ -> [(Id, t)]
addExportFlags target exports keep_alive prs rules
= [(add_export bndr, rhs) | (bndr,rhs) <- prs]
where
is_exported | target == HscInterpreted = isExternalName
| otherwise = (`elemNameSet` exports)
+ppr_ds_rules :: [CoreRule] -> PprStyle -> Doc
ppr_ds_rules [] = empty
ppr_ds_rules rules
= text "" $$ text "-------------- DESUGARED RULES -----------------" $$
%************************************************************************
\begin{code}
-dsRule :: Module -> IdSet -> LRuleDecl Id -> DsM (Maybe CoreRule)
-dsRule mod in_scope (L loc (HsRule name act vars lhs tv_lhs rhs fv_rhs))
+dsRule :: LRuleDecl Id -> DsM (Maybe CoreRule)
+dsRule (L loc (HsRule name act vars lhs _tv_lhs rhs _fv_rhs))
= putSrcSpanDs loc $
do { let bndrs = [var | RuleBndr (L _ var) <- vars]
; lhs' <- dsLExpr lhs