[GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.2
  (Type checker)                     |
           Keywords:  deriving       |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  GHC rejects
  Unknown/Multiple                   |  valid program
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 This program //should// compile:

 {{{#!hs
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {-# LANGUAGE TypeInType #-}
 module Bug where

 import Data.Kind
 import Data.Proxy

 newtype Wat (x :: Proxy (a :: Type)) = MkWat (Maybe a)
   deriving Eq

 newtype Glurp a = MkGlurp (Wat ('Proxy :: Proxy a))
   deriving Eq
 }}}

 After all, it //should// produce this `Eq (Glurp a)` instance, which
 compiles without issue:

 {{{#!hs
 instance Eq a => Eq (Glurp a) where
   (==) = coerce @(Wat ('Proxy :: Proxy a) -> Wat ('Proxy :: Proxy a) ->
 Bool)
                 @(Glurp a                 -> Glurp a                 ->
 Bool)
                 (==)
 }}}

 But despite my wishful thinking, GHC does not actually do this. In fact,
 the code that GHC tries to generate for an `Eq (Glurp a)` instance is
 completely wrong:

 {{{
 $ /opt/ghc/8.2.2/bin/ghci -ddump-deriv Bug.hs
 GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Bug              ( Bug.hs, interpreted )

 ==================== Derived instances ====================
 Derived class instances:
   instance forall a (x :: Data.Proxy.Proxy a).
            GHC.Classes.Eq a =>
            GHC.Classes.Eq (Bug.Wat x) where
     (GHC.Classes.==)
       = GHC.Prim.coerce
           @(GHC.Base.Maybe a_a2wE -> GHC.Base.Maybe a_a2wE ->
 GHC.Types.Bool)
           @(Bug.Wat x_a2wF -> Bug.Wat x_a2wF -> GHC.Types.Bool)
           (GHC.Classes.==)
     (GHC.Classes./=)
       = GHC.Prim.coerce
           @(GHC.Base.Maybe a_a2wE -> GHC.Base.Maybe a_a2wE ->
 GHC.Types.Bool)
           @(Bug.Wat x_a2wF -> Bug.Wat x_a2wF -> GHC.Types.Bool)
           (GHC.Classes./=)

   instance GHC.Classes.Eq a => GHC.Classes.Eq (Bug.Glurp a) where
     (GHC.Classes.==)
       = GHC.Prim.coerce
           @(Bug.Wat Data.Proxy.Proxy
             -> Bug.Wat Data.Proxy.Proxy -> GHC.Types.Bool)
           @(Bug.Glurp a_a1vT -> Bug.Glurp a_a1vT -> GHC.Types.Bool)
           (GHC.Classes.==)
     (GHC.Classes./=)
       = GHC.Prim.coerce
           @(Bug.Wat Data.Proxy.Proxy
             -> Bug.Wat Data.Proxy.Proxy -> GHC.Types.Bool)
           @(Bug.Glurp a_a1vT -> Bug.Glurp a_a1vT -> GHC.Types.Bool)
           (GHC.Classes./=)


 Derived type family instances:



 Bug.hs:12:12: error:
     • Couldn't match representation of type ‘a0’ with that of ‘a’
         arising from a use of ‘GHC.Prim.coerce’
       ‘a’ is a rigid type variable bound by
         the instance declaration at Bug.hs:12:12-13
     • In the expression:
         GHC.Prim.coerce
           @(Wat Proxy -> Wat Proxy -> Bool)
           @(Glurp a -> Glurp a -> Bool)
           (==)
       In an equation for ‘==’:
           (==)
             = GHC.Prim.coerce
                 @(Wat Proxy -> Wat Proxy -> Bool)
                 @(Glurp a -> Glurp a -> Bool)
                 (==)
       When typechecking the code for ‘==’
         in a derived instance for ‘Eq (Glurp a)’:
         To see the code I am typechecking, use -ddump-deriv
       In the instance declaration for ‘Eq (Glurp a)’
     • Relevant bindings include
         (==) :: Glurp a -> Glurp a -> Bool (bound at Bug.hs:12:12)
    |
 12 |   deriving Eq
    |            ^^

 Bug.hs:12:12: error:
     • Could not deduce (Eq a0) arising from a use of ‘==’
       from the context: Eq a
         bound by the instance declaration at Bug.hs:12:12-13
       The type variable ‘a0’ is ambiguous
       These potential instances exist:
         instance forall k (s :: k). Eq (Proxy s) -- Defined in
 ‘Data.Proxy’
         instance Eq Ordering -- Defined in ‘GHC.Classes’
         instance Eq Integer
           -- Defined in ‘integer-gmp-1.0.1.0:GHC.Integer.Type’
         ...plus 25 others
         ...plus 9 instances involving out-of-scope types
         (use -fprint-potential-instances to see them all)
     • In the third argument of ‘GHC.Prim.coerce’, namely ‘(==)’
       In the expression:
         GHC.Prim.coerce
           @(Wat Proxy -> Wat Proxy -> Bool)
           @(Glurp a -> Glurp a -> Bool)
           (==)
       In an equation for ‘==’:
           (==)
             = GHC.Prim.coerce
                 @(Wat Proxy -> Wat Proxy -> Bool)
                 @(Glurp a -> Glurp a -> Bool)
                 (==)
       When typechecking the code for ‘==’
         in a derived instance for ‘Eq (Glurp a)’:
         To see the code I am typechecking, use -ddump-deriv
    |
 12 |   deriving Eq
    |            ^^

 Bug.hs:12:12: error:
     • Couldn't match representation of type ‘a1’ with that of ‘a’
         arising from a use of ‘GHC.Prim.coerce’
       ‘a’ is a rigid type variable bound by
         the instance declaration at Bug.hs:12:12-13
     • In the expression:
         GHC.Prim.coerce
           @(Wat Proxy -> Wat Proxy -> Bool)
           @(Glurp a -> Glurp a -> Bool)
           (/=)
       In an equation for ‘/=’:
           (/=)
             = GHC.Prim.coerce
                 @(Wat Proxy -> Wat Proxy -> Bool)
                 @(Glurp a -> Glurp a -> Bool)
                 (/=)
       When typechecking the code for ‘/=’
         in a derived instance for ‘Eq (Glurp a)’:
         To see the code I am typechecking, use -ddump-deriv
       In the instance declaration for ‘Eq (Glurp a)’
     • Relevant bindings include
         (/=) :: Glurp a -> Glurp a -> Bool (bound at Bug.hs:12:12)
    |
 12 |   deriving Eq
    |            ^^

 Bug.hs:12:12: error:
     • Could not deduce (Eq a1) arising from a use of ‘/=’
       from the context: Eq a
         bound by the instance declaration at Bug.hs:12:12-13
       The type variable ‘a1’ is ambiguous
       These potential instances exist:
         instance forall k (s :: k). Eq (Proxy s) -- Defined in
 ‘Data.Proxy’
         instance Eq Ordering -- Defined in ‘GHC.Classes’
         instance Eq Integer
           -- Defined in ‘integer-gmp-1.0.1.0:GHC.Integer.Type’
         ...plus 25 others
         ...plus 9 instances involving out-of-scope types
         (use -fprint-potential-instances to see them all)
     • In the third argument of ‘GHC.Prim.coerce’, namely ‘(/=)’
       In the expression:
         GHC.Prim.coerce
           @(Wat Proxy -> Wat Proxy -> Bool)
           @(Glurp a -> Glurp a -> Bool)
           (/=)
       In an equation for ‘/=’:
           (/=)
             = GHC.Prim.coerce
                 @(Wat Proxy -> Wat Proxy -> Bool)
                 @(Glurp a -> Glurp a -> Bool)
                 (/=)
       When typechecking the code for ‘/=’
         in a derived instance for ‘Eq (Glurp a)’:
         To see the code I am typechecking, use -ddump-deriv
    |
 12 |   deriving Eq
    |            ^^
 }}}

 Yikes. To see what went wrong, let's zoom in a particular part of the
 `-ddump-deriv` output (cleaned up a bit for presentation purposes):

 {{{#!hs
   instance Eq a => Eq (Glurp a) where
     (==)
       = coerce
           @(Wat 'Proxy -> Wat 'Proxy -> Bool)
           @(Glurp a -> Glurp a -> Bool)
           (==)
 }}}

 Notice that it's `Wat 'Proxy`, and not `Wat ('Proxy :: Proxy a)`! And no,
 that's not just a result of GHC omitting the kind information—you will see
 the exact same thing if you compile with `-fprint-explicit-kinds`. What's
 going on here?

 As it turns out, the types inside of those visible type applications
 aren't `Type`s, but rather `HsType GhcRn`s (i.e., source syntax). So what
 is happening is that GHC is literally producing `@(Wat 'Proxy -> Wat
 'Proxy -> Bool)` //as source syntax//, not as a `Type`. This means that
 `'Proxy` has an underspecified kind, resulting in the numerous `The type
 variable ‘a0’ is ambiguous` errors you see above.

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Hm... look at `TcGenDeriv.nlHsAppType`.  Presumably you want to add the
 necessary kind signatures when doing `typeToHsType`.

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * status:  new => patch
 * differential:   => Phab:D4264


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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 What change to `typeToHsType` do we want? The problem is to specify the
 invisible kind arguments to occurrences of poly-kinded type-constructor
 applications.  Eg
 {{{
 instance Eq a => Eq (Glurp a) where
     (==)
       = coerce
           @(Wat 'Proxy -> Wat 'Proxy -> Bool)
           @(Glurp a -> Glurp a -> Bool)
           (==)
 }}}
 The problem is the invisible kind arguments to the poly-kinded `'Proxy`
 occurrences.  If we had visible kind application we could use that, but we
 don't.  Solution: add a kind signature, as in the Description:
 {{{
 instance Eq a => Eq (Glurp a) where
   (==) = coerce @(Wat ('Proxy :: Proxy a) -> Wat ('Proxy :: Proxy a) ->
 Bool)
                 @(Glurp a                 -> Glurp a                 ->
 Bool)
                 (==)
 }}}
 When do we need a kind signature?

 * (a) When we have an application of a type constructor with invisible
 arguments
 * (b) And the invisible arguments are not fixed by the kinds of the
 visible arguments.

 Probably just using (a) is enough to reduce the noise of redundant kind
 signatures
 to reasonable levels.

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 Is there any reason we can't say

 {{{#!hs
 typeToLHsType = noLoc . HsCoreTy
 }}}

 ? That certainly seems to save a lot of huffing and puffing.

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Good thought.   But these types have free type variables, bound by the
 instance decl. I'm far from sure they'd line up right.

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 simonpj's hunch appears to be right—I just attempted to compile GHC with
 goldfire's suggested change, and wound up face-first in panictown:

 {{{
 libraries/base/GHC/Generics.hs:811:13: error:ghc-stage1: panic! (the
 'impossible' happened)
   (GHC version 8.5.20171213 for x86_64-unknown-linux):
         No skolem info:
   [p3_a3Jl]
   Call stack:
       CallStack (from HasCallStack):
         callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in
 ghc:Outputable
         pprPanic, called at compiler/typecheck/TcErrors.hs:2892:5 in
 ghc:TcErrors
 }}}

 I'll try simonpj's suggested refactoring in comment:3.

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 Ryan's visit to panictown notwithstanding, I'm still not convinced by
 comment:5. comment:5 seems to be suggesting that we need the generated
 code to pass through the renamer, so that the type variables can be
 captured. This is a reasonable guess. But `typeToLHsType`, as currently
 written (and working), uses `Exact` names, so the journey through the
 renamer doesn't capture anything. Perhaps the panic is actually caused by
 these lines in !RnTypes:

 {{{#!hs
 rnHsTyKi _ (HsCoreTy ty)
   = return (HsCoreTy ty, emptyFVs)
     -- The emptyFVs probably isn't quite right
     -- but I don't think it matters
 }}}

 Maybe it matters. Or maybe I'm missing something more fundamental.

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 I think it would be worthwhile to investigate this issue further (probably
 in another Trac ticket). My gut feeling is that Phab:D4264 is simple
 enough that we can adopt it without too much worry—worst comes to worst,
 we can scrap the current implementation of `typeToLHsType` in favor of
 something simpler later.

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Ryan Scott <ryan.gl.scott@…>):

 In [changeset:"649e777211fe08432900093002547d7358f92d82/ghc" 649e777/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="649e777211fe08432900093002547d7358f92d82"
 Make typeToLHsType produce kind signatures for tycon applications

 Summary:
 `GeneralizedNewtypeDeriving` generates calls to `coerce`
 which take visible type arguments. These types must be produced by
 way of `typeToLHsType`, which converts a `Type` to an `LHsType`.
 However, `typeToLHsType` was leaving off important kind information
 when a `Type` contained a poly-kinded tycon application, leading to
 incorrectly generated code in #14579.

 This fixes the issue by tweaking `typeToLHsType` to generate
 explicit kind signatures for tycon applications. This makes the
 generated code noisier, but at least the program from #14579 now
 works correctly.

 Test Plan: make test TEST=T14579

 Reviewers: simonpj, bgamari

 Reviewed By: simonpj

 Subscribers: rwbarton, thomie, carter

 GHC Trac Issues: #14579

 Differential Revision: https://phabricator.haskell.org/D4264
 }}}

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  merge
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  GHC rejects       |            Test Case:
  valid program                      |  deriving/should_compile/T14579
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * testcase:   => deriving/should_compile/T14579
 * status:  patch => merge
 * milestone:   => 8.4.1


Comment:

 Could merge to 8.4.1 if convenient.

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler (Type    |              Version:  8.2.2
  checker)                           |
      Resolution:  fixed             |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  GHC rejects       |            Test Case:
  valid program                      |  deriving/should_compile/T14579
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by bgamari):

 * status:  merge => closed
 * resolution:   => fixed


Comment:

 Merged in ebf8e07629.

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

_______________________________________________
ghc-tickets mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets