From ae5c17c95dab813e0fd7edccaf7cc34162fd166f Mon Sep 17 00:00:00 2001 From: simonpj Date: Fri, 12 Nov 1999 12:51:50 +0000 Subject: [PATCH] [project @ 1999-11-12 12:51:50 by simonpj] Document no deriving for existentials --- ghc/docs/users_guide/glasgow_exts.vsgml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ghc/docs/users_guide/glasgow_exts.vsgml b/ghc/docs/users_guide/glasgow_exts.vsgml index 9830183..d54e919 100644 --- a/ghc/docs/users_guide/glasgow_exts.vsgml +++ b/ghc/docs/users_guide/glasgow_exts.vsgml @@ -1,5 +1,5 @@ % -% $Id: glasgow_exts.vsgml,v 1.18 1999/11/01 16:06:34 simonpj Exp $ +% $Id: glasgow_exts.vsgml,v 1.19 1999/11/12 12:51:50 simonpj Exp $ % % GHC Language Extensions. % @@ -1516,6 +1516,25 @@ because the data version does carry an implementation cost, but single-field existentially quantified constructors aren't much use. So the simple restriction (no existential stuff on newtype) stands, unless there are convincing reasons to change it. + + + You can't use deriving to define instances of a +data type with existentially quantified data constructors. + +Reason: in most cases it would not make sense. For example:# + + data T = forall a. MkT [a] deriving( Eq ) + +To derive Eq in the standard way we would need to have equality +between the single component of two MkT constructors: + + instance Eq T where + (MkT a) == (MkT b) = ??? + +But a and b have distinct types, and so can't be compared. +It's just about possible to imagine examples in which the derived instance +would make sense, but it seems altogether simpler simply to prohibit such +declarations. Define your own instances! -- 1.7.10.4