[commit: ghc] no-pred-ty: Disallow type families in instance heads (baf5d86)

Max Bolingbroke batterseapower at hotmail.com
Sun Sep 4 13:54:44 CEST 2011


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

On branch  : no-pred-ty

http://hackage.haskell.org/trac/ghc/changeset/baf5d86e7d5249acd7cfe949018e804480f7acc7

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

commit baf5d86e7d5249acd7cfe949018e804480f7acc7
Author: Max Bolingbroke <batterseapower at hotmail.com>
Date:   Sat Sep 3 10:43:29 2011 +0100

    Disallow type families in instance heads

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

 compiler/typecheck/TcMType.lhs |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/compiler/typecheck/TcMType.lhs b/compiler/typecheck/TcMType.lhs
index 565549d..9213669 100644
--- a/compiler/typecheck/TcMType.lhs
+++ b/compiler/typecheck/TcMType.lhs
@@ -1173,8 +1173,12 @@ check_pred_ty' dflags ctxt (IrredPred pred)
     -- (Foo a) class constraint we add a (Fooish () a) constraint which will be immediately
     -- solved to add+canonicalise another (Foo a) constraint.
     --
-    -- It's OK if the predicate is actually a synonym, though.
-  | case ctxt of ClassSCCtxt _ | Nothing <- mb_pred' -> False; _ -> True 
+    -- It is equally dangerous to allow them in instance heads because in that case the
+    -- Paterson conditions may not detect duplication of a type variable or size change.
+    --
+    -- In both cases it's OK if the predicate is actually a synonym, though.
+  | isJust mb_pred' ||
+    (case ctxt of ClassSCCtxt _ -> False; InstThetaCtxt -> False; _ -> True)
   = do { checkTc (xopt Opt_ConstraintKind dflags)
                  (predIrredErr pred)
          -- If this is actually a type synonym we should look through it to check for





More information about the Cvs-ghc mailing list