[GHC] #8165: Use GeneralizedNewtypeDeriving to automatically create associated type families

GHC ghc-devs at haskell.org
Wed Mar 4 10:30:10 UTC 2015


#8165: Use GeneralizedNewtypeDeriving to automatically create associated type
families
-------------------------------------+-------------------------------------
        Reporter:  MikeIzbicki       |                   Owner:  goldfire
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:  7.12.1
       Component:  Compiler (Type    |                 Version:  7.6.3
  checker)                           |                Keywords:
      Resolution:                    |            Architecture:
Operating System:  Unknown/Multiple  |  Unknown/Multiple
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by simonpj):

 So, to be more specific, the recipe is this:
 {{{
 class C a where
   type T a
   op :: a -> a

 newtype T a = MkT <rep-type> deriving( C )
 }}}
 Here the `deriving` clause would generate
 {{{
 instance C <rep-type> => C (T a) where
   type T (T a) = T <rep-type>
   op = coerce (op :: <rep-type> -> <rep-type>)
 }}}
 As usual, a wiki page to explain the details when we have to eta-reduce
 the newtype, etc, would be helpful.

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8165#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list