X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FdeSugar%2FDsMonad.lhs;h=83a5d212ae84eb720408de651dc585db50676ba0;hb=7bb3d1fc79521d591cd9f824893963141a7997b6;hp=1f01e1509488330fbdad886f719a455e9260242e;hpb=872148019c5c4fe7f96b12d1610234a2933696f1;p=ghc-hetmet.git diff --git a/compiler/deSugar/DsMonad.lhs b/compiler/deSugar/DsMonad.lhs index 1f01e15..83a5d21 100644 --- a/compiler/deSugar/DsMonad.lhs +++ b/compiler/deSugar/DsMonad.lhs @@ -14,7 +14,7 @@ module DsMonad ( newLocalName, duplicateLocalDs, newSysLocalDs, newSysLocalsDs, newUniqueId, - newFailLocalDs, + newFailLocalDs, newPredVarDs, getSrcSpanDs, putSrcSpanDs, getModuleDs, newUnique, @@ -156,7 +156,7 @@ data DsMetaVal 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 @@ -170,7 +170,6 @@ 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 @@ -180,7 +179,7 @@ initDs hsc_env mod rdr_env type_env thing_inside -- 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 @@ -225,12 +224,22 @@ newUniqueId :: Name -> Type -> DsM Id 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")) + 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]