Commit 4d8c7c97 authored by's avatar

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.
parent 492303f3
......@@ -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!
......@@ -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]
......@@ -990,8 +990,9 @@
<entry>Enable <link linkend="instance-rules">flexible instances</link>.</entry>
<entry>Enable <link linkend="instance-rules">flexible instances</link>.
Implies <option>-XTypeSynonymInstances</option> </entry>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment