newFailLocalDs,
getSrcLocDs, putSrcLocDs,
getModuleDs,
- getUniqueDs,
+ getUniqueDs, getUniquesDs,
getDOptsDs,
dsLookupGlobalValue,
dsWarn,
DsWarnings,
- DsMatchContext(..), DsMatchKind(..)
+ DsMatchContext(..)
) where
#include "HsVersions.h"
+import TcHsSyn ( TypecheckedPat, TypecheckedMatchContext )
import Bag ( emptyBag, snocBag, Bag )
import ErrUtils ( WarnMsg )
import Id ( mkSysLocal, setIdUnique, Id )
import Var ( TyVar, setTyVarUnique )
import Outputable
import SrcLoc ( noSrcLoc, SrcLoc )
-import TcHsSyn ( TypecheckedPat )
-import Type ( Type )
+import TcType ( Type )
import UniqSupply ( initUs_, splitUniqSupply, uniqFromSupply, uniqsFromSupply,
UniqSM, UniqSupply )
import Unique ( Unique )
-import Util ( zipWithEqual )
import Name ( Name )
-import Name ( lookupNameEnv )
-import HscTypes ( HomeSymbolTable, PersistentCompilerState(..),
- TyThing(..), TypeEnv, lookupType )
import CmdLineOpts ( DynFlags )
infixr 9 `thenDs`
initDs :: DynFlags
-> UniqSupply
- -> (HomeSymbolTable, PersistentCompilerState, TypeEnv)
+ -> (Name -> Id)
-> Module -- module name: for profiling
-> DsM a
-> (a, DsWarnings)
-initDs dflags init_us (hst,pcs,local_type_env) mod action
+initDs dflags init_us lookup mod action
= action dflags init_us lookup noSrcLoc mod emptyBag
- where
- -- This lookup is used for well-known Ids,
- -- such as fold, build, cons etc, so the chances are
- -- it'll be found in the package symbol table. That's
- -- why we don't merge all these tables
- pte = pcs_PTE pcs
- lookup n = case lookupType hst pte n of {
- Just (AnId v) -> v ;
- other ->
- case lookupNameEnv local_type_env n of
- Just (AnId v) -> v ;
- other -> pprPanic "initDS: lookup:" (ppr n)
- }
thenDs :: DsM a -> (a -> DsM b) -> DsM b
andDs :: (a -> a -> a) -> DsM a -> DsM a -> DsM a
getUniqueDs :: DsM Unique
getUniqueDs dflags us genv loc mod warns
- = case (uniqFromSupply us) of { assigned_uniq ->
- (assigned_uniq, warns) }
+ = (uniqFromSupply us, warns)
+
+getUniquesDs :: DsM [Unique]
+getUniquesDs dflags us genv loc mod warns
+ = (uniqsFromSupply us, warns)
getDOptsDs :: DsM DynFlags
getDOptsDs dflags us genv loc mod warns
cloneTyVarsDs :: [TyVar] -> DsM [TyVar]
cloneTyVarsDs tyvars dflags us genv loc mod warns
- = case uniqsFromSupply (length tyvars) us of { uniqs ->
- (zipWithEqual "cloneTyVarsDs" setTyVarUnique tyvars uniqs, warns) }
+ = (zipWith setTyVarUnique tyvars (uniqsFromSupply us), warns)
\end{code}
\begin{code}
newTyVarsDs :: [TyVar] -> DsM [TyVar]
-
newTyVarsDs tyvar_tmpls dflags us genv loc mod warns
- = case uniqsFromSupply (length tyvar_tmpls) us of { uniqs ->
- (zipWithEqual "newTyVarsDs" setTyVarUnique tyvar_tmpls uniqs, warns) }
+ = (zipWith setTyVarUnique tyvar_tmpls (uniqsFromSupply us), warns)
\end{code}
We can also reach out and either set/grab location information from
\begin{code}
data DsMatchContext
- = DsMatchContext DsMatchKind [TypecheckedPat] SrcLoc
+ = DsMatchContext TypecheckedMatchContext [TypecheckedPat] SrcLoc
| NoMatchContext
deriving ()
-
-data DsMatchKind
- = FunMatch Id
- | CaseMatch
- | LambdaMatch
- | PatBindMatch
- | DoBindMatch
- | ListCompMatch
- | LetMatch
- | RecUpdMatch
- deriving ()
\end{code}