[GHC] #9821: DeriveAnyClass support for higher-kinded classes + some more comments
GHC
ghc-devs at haskell.org
Fri Feb 10 21:24:06 UTC 2017
#9821: DeriveAnyClass support for higher-kinded classes + some more comments
-------------------------------------+-------------------------------------
Reporter: dreixel | Owner: dreixel
Type: bug | Status: patch
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 7.9
Resolution: | Keywords: Generics
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #5462, #9968, | Differential Rev(s): Phab:D2961
#12144 |
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott <ryan.gl.scott@…>):
In [changeset:"639e702b6129f501c539b158b982ed8489e3d09c/ghc" 639e702/ghc]:
{{{
#!CommitTicketReference repository="ghc"
revision="639e702b6129f501c539b158b982ed8489e3d09c"
Refactor DeriveAnyClass's instance context inference
Summary:
Currently, `DeriveAnyClass` has two glaring flaws:
* It only works on classes whose argument is of kind `*` or `* -> *`
(#9821).
* The way it infers constraints makes no sense. It basically co-opts the
algorithms used to infer contexts for `Eq` (for `*`-kinded arguments) or
`Functor` (for `(* -> *)`-kinded arguments). This tends to produce
overly
constrained instances, which in extreme cases can lead to legitimate
things
failing to typecheck (#12594). Or even worse, it can trigger GHC panics
(#12144 and #12423).
This completely reworks the way `DeriveAnyClass` infers constraints to fix
these two issues. It now uses the type signatures of the derived class's
methods to infer constraints (and to simplify them). A high-level
description
of how this works is included in the GHC users' guide, and more technical
notes
on what is going on can be found as comments (and a Note) in
`TcDerivInfer`.
Fixes #9821, #12144, #12423, #12594.
Test Plan: ./validate
Reviewers: dfeuer, goldfire, simonpj, austin, bgamari
Subscribers: dfeuer, thomie
Differential Revision: https://phabricator.haskell.org/D2961
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9821#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list