Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alexbiehl-gc
GHC
Commits
ae5c17c9
Commit
ae5c17c9
authored
25 years ago
by
Simon Peyton Jones
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1999-11-12 12:51:50 by simonpj]
Document no deriving for existentials
parent
af9130d1
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/docs/users_guide/glasgow_exts.vsgml
+20
-1
20 additions, 1 deletion
ghc/docs/users_guide/glasgow_exts.vsgml
with
20 additions
and
1 deletion
ghc/docs/users_guide/glasgow_exts.vsgml
+
20
−
1
View file @
ae5c17c9
%
% $Id: glasgow_exts.vsgml,v 1.1
8
1999/11/
01 16:06:34
simonpj Exp $
% $Id: glasgow_exts.vsgml,v 1.1
9
1999/11/
12 12:51:50
simonpj Exp $
%
% GHC Language Extensions.
%
...
...
@@ -1516,6 +1516,25 @@ because the <tt>data</tt> version does carry an implementation cost,
but single-field existentially quantified constructors aren't much
use. So the simple restriction (no existential stuff on <tt>newtype</tt>)
stands, unless there are convincing reasons to change it.
<item> You can't use <tt>deriving</tt> to define instances of a
data type with existentially quantified data constructors.
Reason: in most cases it would not make sense. For example:#
<tscreen><verb>
data T = forall a. MkT [a] deriving( Eq )
</verb></tscreen>
To derive <tt>Eq</tt> in the standard way we would need to have equality
between the single component of two <tt>MkT</tt> constructors:
<tscreen><verb>
instance Eq T where
(MkT a) == (MkT b) = ???
</verb></tscreen>
But <tt>a</tt> and <tt>b</tt> 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!
</itemize>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment