Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Fumiaki Kinoshita
GHC
Commits
e43f05b6
Commit
e43f05b6
authored
Nov 03, 2016
by
Simon Peyton Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add comments from Trac #12768
parent
a977c965
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
compiler/typecheck/TcGenDeriv.hs
compiler/typecheck/TcGenDeriv.hs
+28
-0
No files found.
compiler/typecheck/TcGenDeriv.hs
View file @
e43f05b6
...
...
@@ -1591,6 +1591,33 @@ The type checker checks this code, and it currently requires
so ew have to switch that flag on locally in TcDeriv.genInst.
See #8503 for more discussion.
Note [Newtype-deriving trickiness]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider (Trac #12768):
class C a where { op :: D a => a -> a }
instance C a => C [a] where { op = opList }
opList :: (C a, D [a]) => [a] -> [a]
opList = ...
Now suppose we try GND on this:
newtype N a = MkN [a] deriving( C )
The GND is expecting to get an implementation of op for N by
coercing opList, thus:
instance C a => C (N a) where { op = opN }
opN :: (C a, D (N a)) => N a -> N a
opN = coerce @(D [a] => [a] -> [a])
@(D (N a) => [N a] -> [N a]
opList
But there is no reason to suppose that (D [a]) and (D (N a))
are inter-coercible; these instances might completely different.
So GHC rightly rejects this code.
-}
gen_Newtype_binds
::
SrcSpan
...
...
@@ -1636,6 +1663,7 @@ mkCoerceClassMethEqn :: Class -- the class being derived
->
Id
-- the method to look at
->
Pair
Type
-- See Note [Newtype-deriving instances]
-- See also Note [Newtype-deriving trickiness]
-- The pair is the (from_type, to_type), where to_type is
-- the type of the method we are tyrying to get
mkCoerceClassMethEqn
cls
inst_tvs
inst_tys
rhs_ty
id
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment