Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : type-holes-branch

http://hackage.haskell.org/trac/ghc/changeset/5cf88d2d6a7480144b797794b25a9fef6bdb7bd9

>---------------------------------------------------------------

commit 5cf88d2d6a7480144b797794b25a9fef6bdb7bd9
Author: Thijs Alkemade <[email protected]>
Date:   Tue Jul 17 19:38:33 2012 +0200

    Improve the hole's error messages.
    
    - Don't print the local environment if it's empty.
    - Always use the same quotes.

>---------------------------------------------------------------

 compiler/typecheck/TcErrors.lhs  |    7 ++++---
 compiler/typecheck/TcRnTypes.lhs |    2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/compiler/typecheck/TcErrors.lhs b/compiler/typecheck/TcErrors.lhs
index 4491b10..ba8c824 100644
--- a/compiler/typecheck/TcErrors.lhs
+++ b/compiler/typecheck/TcErrors.lhs
@@ -44,6 +44,7 @@ import FastString
 import Outputable
 import DynFlags
 import Data.List        ( partition, mapAccumL )
+import UniqFM
 \end{code}
 
 %************************************************************************
@@ -410,9 +411,9 @@ mkHoleDeferredError ctxt ct@(CHoleCan { cc_ev = fl, 
cc_hole_ty = ty })
        ; (env2, zonked_ty) <- zonkTidyTcType env0 ty
        ; let (env3, tyvars) = tidyOpenTyVars env2 $ varSetElems zonked_vars
        ; tyvars_msg <- mapM locMsg tyvars
-       ; let msg = addArising orig $ (text "Found hole _ with type") <+> 
pprType zonked_ty
-                                  $$ (text "In scope:" <+> ppr lenv)
+       ; let msg = addArising orig $ (text "Found hole" <+> quotes (text "_") 
<+> text "with type") <+> pprType zonked_ty
                                   $$ (if not $ null tyvars then text "Where:" 
<+> sep tyvars_msg else empty)
+                                  $$ (if not $ isNullUFM lenv then text "In 
scope:" <+> ppr lenv else empty)
        ; mkErrorReport ctxt msg
        }
   where
@@ -422,7 +423,7 @@ mkHoleDeferredError ctxt ct@(CHoleCan { cc_ev = fl, 
cc_hole_ty = ty })
                     MetaTv {} -> do { tyvar <- readMetaTyVar tv
                                     ; case tyvar of
                                         (Indirect ty) -> return $ (quotes $ 
pprType ty) <+> ppr_skol (getSkolemInfo (cec_encl ctxt) tv) (getSrcLoc tv)
-                                        Flexi -> return $ (quotes $ ppr tv) 
<+> text "is a free type variable."
+                                        Flexi -> return $ (quotes $ ppr tv) 
<+> text "is a free type variable"
                                     }
                     det -> return $ ppr det
     ppr_skol given_loc tv_loc
diff --git a/compiler/typecheck/TcRnTypes.lhs b/compiler/typecheck/TcRnTypes.lhs
index 10b363e..36654de 100644
--- a/compiler/typecheck/TcRnTypes.lhs
+++ b/compiler/typecheck/TcRnTypes.lhs
@@ -1556,7 +1556,7 @@ pprO ProcOrigin              = ptext (sLit "a proc 
expression")
 pprO (TypeEqOrigin eq)     = ptext (sLit "an equality") <+> ppr eq
 pprO AnnOrigin             = ptext (sLit "an annotation")
 pprO FunDepOrigin          = ptext (sLit "a functional dependency")
-pprO (HoleOrigin _)     = hsep [ptext (sLit "a use of the hole \"_\"")]
+pprO (HoleOrigin _)     = hsep [ptext (sLit "a use of the hole") <+> quotes 
(ptext $ sLit "_")]
 
 instance Outputable EqOrigin where
   ppr (UnifyOrigin t1 t2) = ppr t1 <+> char '~' <+> ppr t2



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to