newLocalName,
duplicateLocalDs, newSysLocalDs, newSysLocalsDs, newUniqueId,
- newFailLocalDs,
+ newFailLocalDs, newPredVarDs,
getSrcSpanDs, putSrcSpanDs,
getModuleDs,
newUnique,
import UniqSupply
import Name
import NameEnv
-import OccName
import DynFlags
import ErrUtils
-import MonadUtils
import FastString
import Data.IORef
initDs :: HscEnv
-> Module -> GlobalRdrEnv -> TypeEnv
-> DsM a
- -> IO (Maybe a)
+ -> IO (Messages, Maybe a)
-- Print errors and warnings, if any arise
initDs hsc_env mod rdr_env type_env thing_inside
-- Display any errors and warnings
-- Note: if -Werror is used, we don't signal an error here.
; msgs <- readIORef msg_var
- ; printErrorsAndWarnings dflags msgs
; let final_res | errorsFound dflags msgs = Nothing
| otherwise = case either_res of
-- a UserError exception. Then it should have put an error
-- message in msg_var, so we just discard the exception
- ; return final_res }
+ ; return (msgs, final_res) }
initDsTc :: DsM a -> TcM a
initDsTc thing_inside
newUniqueId id = mkSysLocalM (occNameFS (nameOccName id))
duplicateLocalDs :: Id -> DsM Id
-duplicateLocalDs old_local = do
- uniq <- newUnique
- return (setIdUnique old_local uniq)
-
+duplicateLocalDs old_local
+ = do { uniq <- newUnique
+ ; return (setIdUnique old_local uniq) }
+
+newPredVarDs :: PredType -> DsM Var
+newPredVarDs pred
+ | isEqPred pred
+ = do { uniq <- newUnique;
+ ; let name = mkSystemName uniq (mkOccNameFS tcName (fsLit "co_pv"))
+ kind = mkPredTy pred
+ ; return (mkCoVar name kind) }
+ | otherwise
+ = newSysLocalDs (mkPredTy pred)
+
newSysLocalDs, newFailLocalDs :: Type -> DsM Id
-newSysLocalDs = mkSysLocalM (fsLit "ds")
+newSysLocalDs = mkSysLocalM (fsLit "ds")
newFailLocalDs = mkSysLocalM (fsLit "fail")
newSysLocalsDs :: [Type] -> DsM [Id]