X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcDeriv.lhs;h=f86dd64fc269406aa8c8e47a740197b8d1b74d1f;hb=66f73ee4d4130b98d35ec26bba073b2197724011;hp=a273b4ae1795d7593b64c69463aeb5a9f94756f0;hpb=119ede053a062d59dffd63473f126eceff304980;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcDeriv.lhs b/compiler/typecheck/TcDeriv.lhs index a273b4a..f86dd64 100644 --- a/compiler/typecheck/TcDeriv.lhs +++ b/compiler/typecheck/TcDeriv.lhs @@ -877,6 +877,26 @@ extendLocalInstEnv dfuns thing_inside ; setGblEnv env' thing_inside } \end{code} +Note [Deriving context] +~~~~~~~~~~~~~~~~~~~~~~~ +With -fglasgow-exts, we allow things like (C Int a) in the simplified +context for a derived instance declaration, because at a use of this +instance, we might know that a=Bool, and have an instance for (C Int +Bool) + +We nevertheless insist that each predicate meets the termination +conditions. If not, the deriving mechanism generates larger and larger +constraints. Example: + data Succ a = S a + data Seq a = Cons a (Seq (Succ a)) | Nil deriving Show + +Note the lack of a Show instance for Succ. First we'll generate + instance (Show (Succ a), Show a) => Show (Seq a) +and then + instance (Show (Succ (Succ a)), Show (Succ a), Show a) => Show (Seq a) +and so on. Instead we want to complain of no instance for (Show (Succ a)). + + %************************************************************************ %* * \subsection[TcDeriv-normal-binds]{Bindings for the various classes}