Commit 87214801 authored by batterseapower's avatar batterseapower
Browse files

Handle introduction of MkCore in DsMonad and expand API

parent da90115a
...@@ -12,7 +12,7 @@ module DsMonad ( ...@@ -12,7 +12,7 @@ module DsMonad (
foldlM, foldrM, ifOptM, foldlM, foldrM, ifOptM,
Applicative(..),(<$>), Applicative(..),(<$>),
newTyVarsDs, newLocalName, newLocalName,
duplicateLocalDs, newSysLocalDs, newSysLocalsDs, newUniqueId, duplicateLocalDs, newSysLocalDs, newSysLocalsDs, newUniqueId,
newFailLocalDs, newFailLocalDs,
getSrcSpanDs, putSrcSpanDs, getSrcSpanDs, putSrcSpanDs,
...@@ -206,7 +206,6 @@ mkDsEnvs dflags mod rdr_env type_env msg_var ...@@ -206,7 +206,6 @@ mkDsEnvs dflags mod rdr_env type_env msg_var
ds_loc = noSrcSpan } ds_loc = noSrcSpan }
return (gbl_env, lcl_env) return (gbl_env, lcl_env)
\end{code} \end{code}
%************************************************************************ %************************************************************************
...@@ -223,9 +222,7 @@ it easier to read debugging output. ...@@ -223,9 +222,7 @@ it easier to read debugging output.
\begin{code} \begin{code}
-- Make a new Id with the same print name, but different type, and new unique -- Make a new Id with the same print name, but different type, and new unique
newUniqueId :: Name -> Type -> DsM Id newUniqueId :: Name -> Type -> DsM Id
newUniqueId id ty = do newUniqueId id = mkSysLocalM (occNameFS (nameOccName id))
uniq <- newUnique
return (mkSysLocal (occNameFS (nameOccName id)) uniq ty)
duplicateLocalDs :: Id -> DsM Id duplicateLocalDs :: Id -> DsM Id
duplicateLocalDs old_local = do duplicateLocalDs old_local = do
...@@ -233,24 +230,11 @@ duplicateLocalDs old_local = do ...@@ -233,24 +230,11 @@ duplicateLocalDs old_local = do
return (setIdUnique old_local uniq) return (setIdUnique old_local uniq)
newSysLocalDs, newFailLocalDs :: Type -> DsM Id newSysLocalDs, newFailLocalDs :: Type -> DsM Id
newSysLocalDs ty = do newSysLocalDs = mkSysLocalM (fsLit "ds")
uniq <- newUnique newFailLocalDs = mkSysLocalM (fsLit "fail")
return (mkSysLocal (fsLit "ds") uniq ty)
newSysLocalsDs :: [Type] -> DsM [Id] newSysLocalsDs :: [Type] -> DsM [Id]
newSysLocalsDs tys = mapM newSysLocalDs tys newSysLocalsDs tys = mapM newSysLocalDs tys
newFailLocalDs ty = do
uniq <- newUnique
return (mkSysLocal (fsLit "fail") uniq ty)
-- The UserLocal bit just helps make the code a little clearer
\end{code}
\begin{code}
newTyVarsDs :: [TyVar] -> DsM [TyVar]
newTyVarsDs tyvar_tmpls = do
uniqs <- newUniqueSupply
return (zipWith setTyVarUnique tyvar_tmpls (uniqsFromSupply uniqs))
\end{code} \end{code}
We can also reach out and either set/grab location information from We can also reach out and either set/grab location information from
...@@ -281,7 +265,6 @@ warnDs warn = do { env <- getGblEnv ...@@ -281,7 +265,6 @@ warnDs warn = do { env <- getGblEnv
; let msg = mkWarnMsg loc (ds_unqual env) ; let msg = mkWarnMsg loc (ds_unqual env)
(ptext (sLit "Warning:") <+> warn) (ptext (sLit "Warning:") <+> warn)
; updMutVar (ds_msgs env) (\ (w,e) -> (w `snocBag` msg, e)) } ; updMutVar (ds_msgs env) (\ (w,e) -> (w `snocBag` msg, e)) }
where
failWithDs :: SDoc -> DsM a failWithDs :: SDoc -> DsM a
failWithDs err failWithDs err
...@@ -290,10 +273,12 @@ failWithDs err ...@@ -290,10 +273,12 @@ failWithDs err
; let msg = mkErrMsg loc (ds_unqual env) err ; let msg = mkErrMsg loc (ds_unqual env) err
; updMutVar (ds_msgs env) (\ (w,e) -> (w, e `snocBag` msg)) ; updMutVar (ds_msgs env) (\ (w,e) -> (w, e `snocBag` msg))
; failM } ; failM }
where
\end{code} \end{code}
\begin{code} \begin{code}
instance MonadThings (IOEnv (Env DsGblEnv DsLclEnv)) where
lookupThing = dsLookupGlobal
dsLookupGlobal :: Name -> DsM TyThing dsLookupGlobal :: Name -> DsM TyThing
-- Very like TcEnv.tcLookupGlobal -- Very like TcEnv.tcLookupGlobal
dsLookupGlobal name dsLookupGlobal name
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment