[commit: ghc] master: Do not do an ambiguity check on the type in a GHCi ":kind" command (3d0d8d0)

Simon Peyton Jones simonpj at microsoft.com
Tue May 28 10:25:17 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/3d0d8d02b0f1359813eed00c0910cb6729460a13

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

commit 3d0d8d02b0f1359813eed00c0910cb6729460a13
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Mon May 27 17:27:33 2013 +0100

    Do not do an ambiguity check on the type in a GHCi ":kind" command
    
    Otherwise we get errors for polykinded type families;
       type family F a :: *
    Then :k F
    would give an ambiguity check trying to unify (F k1) with (F k2),
    which is all a bit stupid.
    
    I found this when investigating Trac #7939

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

 compiler/typecheck/TcValidity.lhs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/compiler/typecheck/TcValidity.lhs b/compiler/typecheck/TcValidity.lhs
index 3a828da..e232598 100644
--- a/compiler/typecheck/TcValidity.lhs
+++ b/compiler/typecheck/TcValidity.lhs
@@ -61,6 +61,12 @@ import Data.List        ( (\\) )
 \begin{code}
 checkAmbiguity :: UserTypeCtxt -> Type -> TcM ()
 checkAmbiguity ctxt ty
+  | GhciCtxt <- ctxt    -- Allow ambiguous types in GHCi's :kind command
+  = return ()           -- E.g.   type family T a :: *  -- T :: forall k. k -> *
+                        -- Then :k T should work in GHCi, not complain that
+                        -- (T k) is ambiguous!
+
+  | otherwise
   = do { allow_ambiguous <- xoptM Opt_AllowAmbiguousTypes
        ; unless allow_ambiguous $ 
     do {(subst, _tvs) <- tcInstSkolTyVars (varSetElems (tyVarsOfType ty))





More information about the ghc-commits mailing list