-- * One FIXME left to resolve.
--
+{-# 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 FlattenMonad (
-- monad definition
elemVarEnv, lookupVarEnv, lookupVarEnv_NF, delVarEnvList)
import Type (Type, tyConAppTyCon)
import HscTypes (HomePackageTable,
- ExternalPackageState(eps_PTE), HscEnv(hsc_HPT),
+ ExternalPackageState(eps_PTE), HscEnv(..),
TyThing(..), lookupType)
import PrelNames ( fstName, andName, orName,
lengthPName, replicatePName, mapPName, bpermutePName,
import TysPrim ( charPrimTyCon, intPrimTyCon, floatPrimTyCon, doublePrimTyCon )
import PrimOp ( PrimOp(..) )
import PrelInfo ( primOpId )
+import DynFlags (DynFlags)
import CoreSyn (Expr(..), Bind(..), CoreBndr, CoreExpr, CoreBind, mkApps)
import CoreUtils (exprType)
import FastString (FastString)
-- initial value of the flattening state
--
-initialFlattenState :: ExternalPackageState
+initialFlattenState :: DynFlags
+ -> ExternalPackageState
-> HomePackageTable
-> UniqSupply
-> FlattenState
-initialFlattenState eps hpt us =
+initialFlattenState dflags eps hpt us =
FlattenState {
us = us,
env = lookup,
}
where
lookup n =
- case lookupType hpt (eps_PTE eps) n of
+ case lookupType dflags hpt (eps_PTE eps) n of
Just (AnId v) -> v
_ -> pprPanic "FlattenMonad: unknown name:" (ppr n)
-> Flatten a
-> a
runFlatten hsc_env eps us m
- = fst $ unFlatten m (initialFlattenState eps (hsc_HPT hsc_env) us)
+ = fst $ unFlatten m (initialFlattenState (hsc_dflags hsc_env)
+ eps (hsc_HPT hsc_env) us)
-- variable generation