|
|
# Support for generic programming
|
|
|
|
|
|
|
|
|
GHC includes a new (in 2010) mechanism to let you write generic functions. It is described in paper [ A generic deriving mechanism for Haskell](http://www.dreixel.net/research/pdf/gdmh_nocolor.pdf). This page sketches the specifics of the implementation; we assume you have read the paper. The [ HaskellWiki page](http://www.haskell.org/haskellwiki/Generics) gives a more general overview.
|
|
|
GHC includes a new (in 2010) mechanism to let you write generic functions. It is described in paper [A generic deriving mechanism for Haskell](http://www.dreixel.net/research/pdf/gdmh_nocolor.pdf). This page sketches the specifics of the implementation; we assume you have read the paper. The [ HaskellWiki page](http://www.haskell.org/haskellwiki/Generics) gives a more general overview.
|
|
|
|
|
|
|
|
|
This mechanism replaces the [previous generic classes implementation](http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/generic-classes.html). What we describe until the "Kind polymorphic overhaul" section is implemented and released in GHC 7.2.1.
|
... | ... | @@ -15,27 +15,27 @@ Use **Keyword** = `Generics` to ensure that a ticket ends up on this auto-genera |
|
|
|
|
|
Open Tickets:
|
|
|
|
|
|
<table><tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/5642">#5642</a></th>
|
|
|
<table><tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/5642">#5642</a></th>
|
|
|
<td>Deriving Generic of a big type takes a long time and lots of space</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7492">#7492</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7492">#7492</a></th>
|
|
|
<td>Generic1 deriving: Can we replace Rec1 f with f :.: Par1?</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/8516">#8516</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/8516">#8516</a></th>
|
|
|
<td>Add (->) representation and the Invariant class to GHC.Generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/8560">#8560</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/8560">#8560</a></th>
|
|
|
<td>Derive some generic representation for GADTs</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10068">#10068</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10068">#10068</a></th>
|
|
|
<td>Make the runtime reflection API for names, modules, locations more systematic</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10087">#10087</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10087">#10087</a></th>
|
|
|
<td>DefaultSignatures: error message mentions internal name</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10514">#10514</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10514">#10514</a></th>
|
|
|
<td>Generic for existential types</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11068">#11068</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11068">#11068</a></th>
|
|
|
<td>Make Generic/Generic1 methods inlinable</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12731">#12731</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12731">#12731</a></th>
|
|
|
<td>Generic type class has type family; leads to big dep_finsts</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13065">#13065</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13065">#13065</a></th>
|
|
|
<td>Prohibit user-defined Generic and Generic1 instances</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/15969">#15969</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/15969">#15969</a></th>
|
|
|
<td>Generic1 deriving should use more coercions</td></tr></table>
|
|
|
|
|
|
|
... | ... | @@ -43,131 +43,131 @@ Open Tickets: |
|
|
|
|
|
Closed Tickets:
|
|
|
|
|
|
<table><tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/2824">#2824</a></th>
|
|
|
<table><tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/2824">#2824</a></th>
|
|
|
<td>Duplicate symbols generated when Generics flag and syb-with-class "derive" used simultaneously</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/3391">#3391</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/3391">#3391</a></th>
|
|
|
<td>Generics compilation failure in combination with Data.Accessor deriving</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/5220">#5220</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/5220">#5220</a></th>
|
|
|
<td>GHC internal error when missing -XFlexibleContexts with generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/5227">#5227</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/5227">#5227</a></th>
|
|
|
<td>Large space usage when deriving Generic</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/5462">#5462</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/5462">#5462</a></th>
|
|
|
<td>Deriving clause for arbitrary classes</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/5464">#5464</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/5464">#5464</a></th>
|
|
|
<td>Change the way the extra bindings for the generic representation are generated</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/5884">#5884</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/5884">#5884</a></th>
|
|
|
<td>GHC panics while trying to derive a Generic instance for Complex a</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/5936">#5936</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/5936">#5936</a></th>
|
|
|
<td>Support for data families in generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/5939">#5939</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/5939">#5939</a></th>
|
|
|
<td>Standalone deriving Generic on type with instantiated arguments</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7035">#7035</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7035">#7035</a></th>
|
|
|
<td>`deriving instance Generic (HsExpr Id)` raises panic</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7255">#7255</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7255">#7255</a></th>
|
|
|
<td>Wrong suggestion when deriving Generic on an instantiated type</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7263">#7263</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7263">#7263</a></th>
|
|
|
<td>Add derived Show instances to GHC.Generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7346">#7346</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7346">#7346</a></th>
|
|
|
<td>Allow the use of `deriving` for GHC generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7422">#7422</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7422">#7422</a></th>
|
|
|
<td>GHC panics while trying to derive Generic for GADT with kind-lifted phantom parameter</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7444">#7444</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7444">#7444</a></th>
|
|
|
<td>Update documentation regarding derivability of Generic1</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7459">#7459</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7459">#7459</a></th>
|
|
|
<td>deriving Generic does not work with TypeLits</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7487">#7487</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7487">#7487</a></th>
|
|
|
<td>Deriving Generic1 for a type containing Either</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7631">#7631</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7631">#7631</a></th>
|
|
|
<td>Allow to differentiate between newtypes and datatypes when using Generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/7878">#7878</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/7878">#7878</a></th>
|
|
|
<td>Panic when using DerivingGeneric with hs-boot</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/8416">#8416</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/8416">#8416</a></th>
|
|
|
<td>GHC.Generics needs more documentation</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/8468">#8468</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/8468">#8468</a></th>
|
|
|
<td>ghc panic in deriving Generic1 on Array#</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/8479">#8479</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/8479">#8479</a></th>
|
|
|
<td>Generic1 crashes with tyConStupidTheta when using associated type families</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/8797">#8797</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/8797">#8797</a></th>
|
|
|
<td>Generics instances for monoid and applicative newtypes</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/8929">#8929</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/8929">#8929</a></th>
|
|
|
<td>Deriving Generics broken</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9043">#9043</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9043">#9043</a></th>
|
|
|
<td>Add missing type class instances for data types in GHC.Generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9453">#9453</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9453">#9453</a></th>
|
|
|
<td>The example for GHC Generics is kinda broken</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9523">#9523</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9523">#9523</a></th>
|
|
|
<td>Typo in GHC Generics documentation</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9526">#9526</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9526">#9526</a></th>
|
|
|
<td>Add missing Generic instances in base</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9527">#9527</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9527">#9527</a></th>
|
|
|
<td>Add Generic instances for Language.Haskell.TH</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9563">#9563</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9563">#9563</a></th>
|
|
|
<td>Support for deriving Generic1 for data families</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9630">#9630</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9630">#9630</a></th>
|
|
|
<td>compile-time performance regression (probably due to Generics)</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9766">#9766</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9766">#9766</a></th>
|
|
|
<td>Use TypeLits in the meta-data encoding of GHC.Generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9821">#9821</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9821">#9821</a></th>
|
|
|
<td>DeriveAnyClass support for higher-kinded classes + some more comments</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/9968">#9968</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/9968">#9968</a></th>
|
|
|
<td>DeriveAnyClass fails on multi-parameter type classes</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10030">#10030</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10030">#10030</a></th>
|
|
|
<td>packageName for GHC.Generics.Datatype</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10361">#10361</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10361">#10361</a></th>
|
|
|
<td>DeriveAnyClass does not fill in associated type defaults</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10487">#10487</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10487">#10487</a></th>
|
|
|
<td>DeriveGeneric breaks when the same data name is used in different modules</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10512">#10512</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10512">#10512</a></th>
|
|
|
<td>Generic instances missing for Int32, Word64 etc.</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10513">#10513</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10513">#10513</a></th>
|
|
|
<td>ghc 7.6.3 Compiler panic with Generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10598">#10598</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10598">#10598</a></th>
|
|
|
<td>DeriveAnyClass and GND don't work well together</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10604">#10604</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10604">#10604</a></th>
|
|
|
<td>Make Generic1 kind polymorphic</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10669">#10669</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10669">#10669</a></th>
|
|
|
<td>Missing Generic instances for base types.</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10716">#10716</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10716">#10716</a></th>
|
|
|
<td>Metadata in GHC.Generic should give access to strictness annotation</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10775">#10775</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10775">#10775</a></th>
|
|
|
<td>Enable PolyKinds in GHC.Generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10852">#10852</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10852">#10852</a></th>
|
|
|
<td>ghc 7.8.4 on arm - panic: Simplifier ticks exhausted</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/10868">#10868</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/10868">#10868</a></th>
|
|
|
<td>Make GHC generics capable of handling unboxed types</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11292">#11292</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11292">#11292</a></th>
|
|
|
<td>Generics unboxed types: TEST=GEq1 WAY=optasm is failing</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11357">#11357</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11357">#11357</a></th>
|
|
|
<td>Regression when deriving Generic1 on poly-kinded data family</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11358">#11358</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11358">#11358</a></th>
|
|
|
<td>GHC generics has differing conFixity behavior between 7.10.3 and 8.1</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11415">#11415</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11415">#11415</a></th>
|
|
|
<td>pandoc-types fails to build on 4 GB machine</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11703">#11703</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11703">#11703</a></th>
|
|
|
<td>Segmentation fault/internal error: evacuate: strange closure type 15 with GHC.Generics</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11732">#11732</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11732">#11732</a></th>
|
|
|
<td>Deriving Generic1 interacts poorly with TypeInType</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11775">#11775</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11775">#11775</a></th>
|
|
|
<td>singleton classes in ghc.generics are defined but not exported</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/11991">#11991</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/11991">#11991</a></th>
|
|
|
<td>Generics deriving is quadratic</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12144">#12144</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12144">#12144</a></th>
|
|
|
<td>GHC panic when using DeriveAnyClass with functor-like class and datatype with a type variable in a contravariant position</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12367">#12367</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12367">#12367</a></th>
|
|
|
<td>Commit adding instances to GHC.Generics regression compiler performance</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12423">#12423</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12423">#12423</a></th>
|
|
|
<td>Panic with DeriveAnyClass</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/12594">#12594</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/12594">#12594</a></th>
|
|
|
<td>DeriveAnyClass fails to derive some classes</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13059">#13059</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13059">#13059</a></th>
|
|
|
<td>High memory usage during compilation</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13206">#13206</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13206">#13206</a></th>
|
|
|
<td>Error in GHC.Generics documentation</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13272">#13272</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13272">#13272</a></th>
|
|
|
<td>DeriveAnyClass regression involving a rigid type variable</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13314">#13314</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13314">#13314</a></th>
|
|
|
<td>StandaloneDeriving and DeriveAnyClass don't work together</td></tr>
|
|
|
<tr><th><a href="https://gitlab.haskell.org//ghc/ghc/issues/13919">#13919</a></th>
|
|
|
<tr><th><a href="https://gitlab.haskell.org/ghc/ghc/issues/13919">#13919</a></th>
|
|
|
<td>Incorrect unused top binding warning when interacting with GHC.Generics</td></tr></table>
|
|
|
|
|
|
|
... | ... | @@ -210,7 +210,7 @@ Closed Tickets: |
|
|
# Differences from original paper
|
|
|
|
|
|
|
|
|
GHC generics was originally based off of the paper [ A Generic Deriving Mechanism for Haskell](http://www.dreixel.net/research/pdf/gdmh_nocolor.pdf) (referred to henceforth as GDMH), but GHC generics has diverged from the original presentation in the paper since then. Here are some of the differences:
|
|
|
GHC generics was originally based off of the paper [A Generic Deriving Mechanism for Haskell](http://www.dreixel.net/research/pdf/gdmh_nocolor.pdf) (referred to henceforth as GDMH), but GHC generics has diverged from the original presentation in the paper since then. Here are some of the differences:
|
|
|
|
|
|
- What GDMH called `Representable0` and `Representable1` are now called `Generic` and `Generic1`
|
|
|
- GDMH has a type `Par0` for denoting occurrences of the last type parameter of a datatype in a `Generic` instance. GHC generics, however, does not use `Par0` anymore in derived instances (after all, you can have `Generic` instances for datatypes without type parameters!), and the `Par0` type has been marked as deprecated.
|
... | ... | @@ -548,7 +548,7 @@ data DecidedStrictness = DecidedLazy |
|
|
```
|
|
|
|
|
|
|
|
|
Why did we need to add `FixityI`? Because `Fixity` does not promote. Yet, we wanted to expose `Fixity` to the user, not `FixityI`. Note that the meta-data classes remained mostly unchanged (aside from some enhancements to [ Datatype](https://ghc.haskell.org/trac/ghc/ticket/10030) and [ Selector](https://ghc.haskell.org/trac/ghc/ticket/10716)):
|
|
|
Why did we need to add `FixityI`? Because `Fixity` does not promote. Yet, we wanted to expose `Fixity` to the user, not `FixityI`. Note that the meta-data classes remained mostly unchanged (aside from some enhancements to [Datatype](https://ghc.haskell.org/trac/ghc/ticket/10030) and [ Selector](https://ghc.haskell.org/trac/ghc/ticket/10716)):
|
|
|
|
|
|
```wiki
|
|
|
class Datatype d where
|
... | ... | @@ -682,7 +682,7 @@ data DecidedStrictness = DecidedLazy |
|
|
```
|
|
|
|
|
|
|
|
|
This design draws much inspiration from the way Template Haskell handles strictness as of GHC 8.0 (see [ here](https://ghc.haskell.org/trac/ghc/ticket/10697) for what motivated the change). We make a distinction between the *source* strictness annotations and the strictness GHC actually *decides* during compilation. To illustrate the difference, consider the following data type:
|
|
|
This design draws much inspiration from the way Template Haskell handles strictness as of GHC 8.0 (see [here](https://ghc.haskell.org/trac/ghc/ticket/10697) for what motivated the change). We make a distinction between the *source* strictness annotations and the strictness GHC actually *decides* during compilation. To illustrate the difference, consider the following data type:
|
|
|
|
|
|
|
|
|
```
|
... | ... | @@ -748,7 +748,7 @@ data MyDatatype = .... deriving (Generic, GBinary) |
|
|
Ultimately, this might even allow us to replace the generated code by classes such as `Eq`, `Ord`, etc. with plain generic code.
|
|
|
|
|
|
|
|
|
The ticket for this request is [\#5462](https://gitlab.haskell.org//ghc/ghc/issues/5462). We refer to this new feature as `DeriveAnyClass`.
|
|
|
The ticket for this request is [\#5462](https://gitlab.haskell.org/ghc/ghc/issues/5462). We refer to this new feature as `DeriveAnyClass`.
|
|
|
|
|
|
## Which classes can be derived?
|
|
|
|
... | ... | @@ -1059,7 +1059,7 @@ instance Generic IntHash where |
|
|
# Compilation performance tricks
|
|
|
|
|
|
|
|
|
Unfortunately, deriving `Generic` has been known to incur large compilation times. It is suspected that deriving `Generic` has both nonlinear behavior as well as a large constant overhead (see [\#5642](https://gitlab.haskell.org//ghc/ghc/issues/5642) for further discussion). This section discusses some of the tricks GHC developers have used to make deriving `Generic` faster.
|
|
|
Unfortunately, deriving `Generic` has been known to incur large compilation times. It is suspected that deriving `Generic` has both nonlinear behavior as well as a large constant overhead (see [\#5642](https://gitlab.haskell.org/ghc/ghc/issues/5642) for further discussion). This section discusses some of the tricks GHC developers have used to make deriving `Generic` faster.
|
|
|
|
|
|
## Factoring out `M1`
|
|
|
|
... | ... | |