From 4d8c7c976104d2e39a1183967ec0f254a0fc0a47 Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Tue, 14 Dec 2010 17:47:55 +0000 Subject: [PATCH] Fix Trac #4841: behave right with TypeSynonymInstances and NoFlexibleInstances When we have TypeSynonymInstances without FlexibleInstances we should still insist on a H98-style instance head, after looking through the synonym. This patch also make FlexibleInstances imply TypeSynonymInstances. Anything else is a bit awkward, and not very useful. --- compiler/main/DynFlags.hs | 1 + compiler/typecheck/TcType.lhs | 3 +++ docs/users_guide/flags.xml | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index e3de006..8f6f45d 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -1658,6 +1658,7 @@ impliedFlags , (Opt_LiberalTypeSynonyms, turnOn, Opt_ExplicitForAll) , (Opt_ExistentialQuantification, turnOn, Opt_ExplicitForAll) , (Opt_PolymorphicComponents, turnOn, Opt_ExplicitForAll) + , (Opt_FlexibleInstances, turnOn, Opt_TypeSynonymInstances) , (Opt_RebindableSyntax, turnOff, Opt_ImplicitPrelude) -- NB: turn off! diff --git a/compiler/typecheck/TcType.lhs b/compiler/typecheck/TcType.lhs index 89aba65..50ac35a 100644 --- a/compiler/typecheck/TcType.lhs +++ b/compiler/typecheck/TcType.lhs @@ -956,6 +956,9 @@ tcInstHeadTyAppAllTyVars :: Type -> Bool -- Used in Haskell-98 mode, for the argument types of an instance head -- These must be a constructor applied to type variable arguments tcInstHeadTyAppAllTyVars ty + | Just ty' <- tcView ty -- Look through synonyms + = tcInstHeadTyAppAllTyVars ty' + | otherwise = case ty of TyConApp _ tys -> ok tys FunTy arg res -> ok [arg, res] diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml index c8e5dfc..2bcb5e6 100644 --- a/docs/users_guide/flags.xml +++ b/docs/users_guide/flags.xml @@ -990,8 +990,9 @@ - Enable flexible instances. - dynamic + Enable flexible instances. + Implies + dynamic -- 1.7.10.4