Handle synonym families in check_tau_type
authorManuel M T Chakravarty <chak@cse.unsw.edu.au>
Tue, 9 Jan 2007 21:55:41 +0000 (21:55 +0000)
committerManuel M T Chakravarty <chak@cse.unsw.edu.au>
Tue, 9 Jan 2007 21:55:41 +0000 (21:55 +0000)
compiler/typecheck/TcMType.lhs

index e2381b6..ca5ca0e 100644 (file)
@@ -81,7 +81,7 @@ import UniqSupply
 import SrcLoc
 import Outputable
 
-import Control.Monad   ( when )
+import Control.Monad   ( when, unless )
 import Data.List       ( (\\) )
 \end{code}
 
@@ -826,12 +826,15 @@ check_tau_type rank ubx_tup ty@(TyConApp tc tys)
                --      type Foo a = Tree [a]
                --      f :: Foo a b -> ...
        ; case tcView ty of
-            Just ty' -> check_tau_type rank ubx_tup ty'        -- Check expansion
-            Nothing  -> failWithTc arity_msg
+            Just ty' -> check_tau_type rank ubx_tup ty' -- Check expansion
+            Nothing -> unless (isOpenTyCon tc           -- No expansion if open
+                               && tyConArity tc <= length tys) $
+                         failWithTc arity_msg
 
        ; gla_exts <- doptM Opt_GlasgowExts
-       ; if gla_exts then
-       -- If -fglasgow-exts then don't check the type arguments
+       ; if gla_exts && not (isOpenTyCon tc) then
+       -- If -fglasgow-exts then don't check the type arguments of 
+       -- *closed* synonyms.
        -- This allows us to instantiate a synonym defn with a 
        -- for-all type, or with a partially-applied type synonym.
        --      e.g.   type T a b = a