[GHC] #15142: GHC HEAD regression: tcTyVarDetails

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

[GHC] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  highest        |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.5
  (Type checker)                     |
           Keywords:  TypeInType,    |  Operating System:  Unknown/Multiple
  TypeFamilies                       |
       Architecture:                 |   Type of failure:  Compile-time
  Unknown/Multiple                   |  crash or panic
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 This regression prevents the `generic-lens` library from building. Here is
 a minimized test case:

 {{{#!hs
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE TypeFamilies #-}
 {-# LANGUAGE TypeInType #-}
 module Bug where

 import Data.Kind

 class ListTuple (tuple :: Type) (as :: [(k, Type)]) where
   type ListToTuple as :: Type
 }}}

 On GHC 8.4.2, this compiles, but on GHC HEAD, it panics:

 {{{
 $ ~/Software/ghc/inplace/bin/ghc-stage2 Bug.hs[1 of 1] Compiling Bug
 ( Bug.hs, Bug.o )
 ghc-stage2: panic! (the 'impossible' happened)
   (GHC version 8.5.20180511 for x86_64-unknown-linux):
         tcTyVarDetails
   co_aWx :: (k_aWt[tau:2] :: *) ~# (* :: *)
   Call stack:
       CallStack (from HasCallStack):
         callStackDoc, called at compiler/utils/Outputable.hs:1162:37 in
 ghc:Outputable
         pprPanic, called at compiler/basicTypes/Var.hs:497:22 in ghc:Var
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142>
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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * cc: goldfire (added)


Comment:

 This was introduced in commit faec8d358985e5d0bf363bd96f23fe76c9e281f7
 (`Track type variable scope more carefully.`).

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Some more observations about this:

 * If you swap out `TypeInType` for just `DataKinds` and `PolyKinds`, then
 the program no longer panics, so `TypeInType` appears to be critical in
 triggering this panic.
 * If you try and give the parameter to `ListToTuple` an explicit kind
 signature:

   {{{#!hs
   {-# LANGUAGE MultiParamTypeClasses #-}
   {-# LANGUAGE TypeFamilies #-}
   {-# LANGUAGE TypeInType #-}
   module Bug where

   import Data.Kind

   class ListTuple (tuple :: Type) (as :: [(k, Type)]) where
     type ListToTuple (as :: [(k, Type)]) :: Type
   }}}

   Then this will typecheck on GHC 8.4.2, but on HEAD it will give an error
 message:

   {{{
   $ ~/Software/ghc/inplace/bin/ghc-stage2 Bug.hs
   [1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

   Bug.hs:9:29: error:
       • Expected a type, but ‘k’ has kind ‘k0’
       • In the kind ‘[(k, Type)]’
     |
   9 |   type ListToTuple (as :: [(k, Type)]) :: Type
     |                             ^
   }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Further observations:

 * `MultiParamTypeClasses` is also important to triggering this, since this
 panics:

   {{{#!hs
   {-# LANGUAGE MultiParamTypeClasses #-}
   {-# LANGUAGE TypeFamilies #-}
   {-# LANGUAGE TypeInType #-}
   module Bug where

   import Data.Kind

   class C (a :: Type) (b :: k) where
     type T b
   }}}

   But not this:

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

   import Data.Kind

   class C (b :: k) where
     type T b
   }}}
 * The order of arguments to `C`, as well as the exact kind signatures
 given to them, also appears to be important, as none of the following
 panics:

   {{{#!hs
   {-# LANGUAGE MultiParamTypeClasses #-}
   {-# LANGUAGE TypeFamilies #-}
   {-# LANGUAGE TypeInType #-}
   module Bug where

   import Data.Kind

   class C1 (b :: k) (a :: Type) where
     type T1 b

   class C2 b (a :: Type) where
     type T2 b

   class C3 b a where
     type T3 b

   class C4 (b :: k) a where
     type T4 b

   class C5 a (b :: k) where
     type T5 b

   class C6 (a :: Type) b where
     type T6 b

   class C7 a b where
     type T7 b
   }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Comparing the results of `-ddump-tc-trace` on this program:

 {{{#!hs
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE TypeFamilies #-}
 {-# LANGUAGE TypeInType #-}
 module Bug where

 import Data.Kind

 class C (a :: Type) (b :: k) where
   type T b
 }}}

 On GHC 8.4.2, we have:

 {{{
 kcTyClGroup: initial kinds
   [r1xu :-> ATcTyCon C :: forall k. * -> k -> Constraint,
    r1xA :-> ATcTyCon T :: forall k. k -> *]
 }}}

 But on GHC HEAD, we have:

 {{{
 kcTyClGroup: initial kinds
   C :: forall k. * -> k -> Constraint
   T :: forall (k :: k_a1zm[tau:1]) (co :: k_a1zm[tau:1]
                                           GHC.Prim.~# *).
        (k |> {co_a1zq}) -> *
 }}}

 And indeed, `tcTyVarDetails` appears to be panicking on `co`. But I
 haven't the foggiest idea of what it's doing there...

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Oh dear, there are lots of thigs wrong here.  I looked at
 {{{
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE TypeFamilies #-}
 {-# LANGUAGE TypeInType #-}
 module Bug where

 import Data.Kind

 class C (a :: Type) (b :: k) where
   type T b
 }}}


 * First, `C` has a CUSK.  But does `T`?  Well `hsCeclHasCusk` reports True
 for the class decl, without even looking at `T`.  This seems wrong.

 * `C` has a CUSK, but in `class C (a :: Type) (b :: k)`, I'm not sore how
 we get to know that `k :: Type`.   Yet, without that `C` would not ahve a
 CUSK.

 * `getInitialKinds` returns this very bogus kind for `T`:
 {{{
 kcTyClGroup: initial kinds
   C :: forall k. * -> k -> Constraint
   T :: forall (k :: k_aWH[tau:1]) (co :: k_aWH[tau:1] GHC.Prim.~# *).
          (k |> {co_aWL}) -> *
 }}}

 * What is that `co` binder?  It's created in the mysterious `kcLHsQTyVars`
 function, which does something very like `quantifyTyVars`, but by steam.
 It uses `tyCoVarsOfTypeWellScoped`, but neglects to filter out coercion
 variables; hence the bugos quantification over `co_aWL`.

 ------------------
 I'm reluctant to reach for a quick fix here.  It all looks very dodgy to
 me.  The `getInitialKinds` function, which is the bit misbehaving here,
 should be very simple:

 * For CUSKs, the idea is that it's a ''complete, user-specified kind'',
 just like a top-level type signature for a term variable.  II expect to do
 something very akin to `tcHsSigType`: that is, type-check the kind, solve
 any constraints that arise, and kind-generalise the result.  It's made a
 bit trickier by the fact that instead of a `LHsSigType` like `forall a.
 a->a` we have some `LHsQTyVars` like `data T (a :: k) (b :: *)`.  But it's
 basically all one kind signature, pretty much the same as `forall (a::k)
 (b::*). blah`

 * For non-CUSKs, we can safely simply make `T :: kappa`, without looking
 at the declaration at all!  We can perhaps save ourselves a bit of
 fruitless unification by seeing that if its `data T (a :: ...) (b :: ...)`
 then we can make `T :: kappa1 -> kappa2 -> *`.  But we don't have to look
 into those "..." parts; that's going to happen later.  No
 `solveEqualities` for non-CUSKs.

 * Associated types should not be allowed to mess things up!  They must be
 treated as CUSK-ish only if they are in fact complete. Fundamentally, the
 same rules should apply: every type variable should be annotated.  But
 maybe we can make an exception for variables from the parent class, if the
 parent class has a CUSK.  Eg
 {{{
 class C (a :: *) where
   type F a (b :: * -> *) :: *
 }}}
   Here perhaps we can allow `a` not to be annotated in `F`'s defn because
 it comes from `C` which itself has a CUSK.

 The present code does not do this, and it's buggy as this ticket shows.
 Let's discuss.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 Oh dear is right. No time to look right now. Will do so next week.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * keywords:  TypeInType, TypeFamilies => TypeInType, TypeFamilies, CUSKs


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by bgamari):

 * owner:  (none) => goldfire


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Simon says: when there is a CUSK, quantify over any free kind variables.
 Example at the term level
 {{{
 f :: forall (a :: Proxy k). Proxy a -> Int
 }}}
 Then we infer (notice the `k2`):
 {{{
 f :: forall k2 (k :: k2). forall (a :: Proxy k). Proxy a -> Int
 }}}
 So similarly at tke type level if we have this CUSK
 {{{
 data T (a :: Proxy k) :: Proxy a -> Type where ...
 }}}
 we should quantify over the kind to get
 {{{
 T :: forall k2 (k :: k2). forall (a :: Proxy k). Proxy a -> Type
 }}}
 This would require changing code in the CUSK case of `kcLHsQTyVars`, which
 currently calls `report_non_cusk_tvs` to complain.   Instead, generalise.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 > For non-CUSKs, we can safely simply make T :: kappa, without looking at
 the declaration at all!

 Actually this is not true, as things stand.  This accepted:
 {{{
 data T k (a::k) = MkT (Proxy (T * Int)) (Proxy (T (*->*) Maybe))
 }}}
 But `T` does not have a CUSK, and if we assigned it the mono-kind `kappa`,
 the recursive definition would be rejected.

 So currently we are cleverly (and somewhat accidentally) accepting a
 recursive definition with a partial kind signature.

 I think we should just reject this definition unless you write a CUSK.
 Specifying exactly what is and what is not accepted would be ...
 difficult.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 This goes back to the kind inference debate we had when working on #14066.
 The debate is memorialized
 [https://ghc.haskell.org/trac/ghc/wiki/GhcKinds/KindInference here],
 toward the top.

 Suppose we have

 {{{#!hs
 data Proxy (k :: Type) (a :: k) = Proxy  -- NB: CUSK
 }}}

 Do we accept

 {{{#!hs
 type ProxySym k a = Proxy k a
 data ProxyData k a = MkProxyData (Proxy k a)
 }}}

 Related are your thoughts on #14847

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#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
Reply | Threaded
Open this post in threaded view
|

Re: [GHC] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 Some thoughts have been written up
 [https://ghc.haskell.org/trac/ghc/wiki/GhcKinds/KindInference#SimplifyinggetInitialKinds15142
 here]. But there's no real progress on what the right answer is.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#comment:12>
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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 I have good news and bad news.

 The bad news is that this still does not typecheck on GHC HEAD.

 The good news is that it no longer panics! It now gives the following,
 lovely error message:

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

 Bug.hs:8:42: error:
     • Expected a type, but ‘k’ has kind ‘k’
     • In the kind ‘[(k, Type)]’
   |
 8 | class ListTuple (tuple :: Type) (as :: [(k, Type)]) where
   |                                          ^
 }}}

 So that's... nice, I guess.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#comment:13>
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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 As far as I can tell, the only available workaround for this issue is to
 explicitly quantify `k`, like so:

 {{{#!hs
 class ListTuple (tuple :: Type) k (as :: [(k, Type)]) where
   type ListToTuple as :: Type
 }}}

 `generic-lens` may need to employ this hack if this issue hasn't been
 fixed by 8.6.1's release.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#comment:14>
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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Richard Eisenberg <rae@…>):

 In [changeset:"030211d21207dabb7a4bf21cc9af6fa5eb066db1/ghc"
 030211d2/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="030211d21207dabb7a4bf21cc9af6fa5eb066db1"
 Kind-check CUSK associated types separately

 Previously, we kind-checked associated types while while still
 figuring out the kind of a CUSK class. This caused trouble, as
 documented in Note [Don't process associated types in kcLHsQTyVars]
 in TcTyClsDecls. This commit moves this process after the initial
 kind of the class is determined.

 Fixes #15142.

 Test case: indexed-types/should_compile/T15142.hs
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#comment:15>
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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  merge
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Compile-time      |            Test Case:  indexed-
  crash or panic                     |  types/should_compile/T15142
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by goldfire):

 * status:  new => merge
 * testcase:   => indexed-types/should_compile/T15142


Comment:

 Fixed now. Please merge.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#comment:16>
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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  merge
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Compile-time      |            Test Case:  indexed-
  crash or panic                     |  types/should_compile/T15142
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 > In 030211d2/ghc:

 Richard, I like this.  The code is simpler, `kcLHsQTyVars` has a simpler
 signature.  All good.

 But you did not respond to these points from comment:5:

 * First, `C` has a CUSK.  But does `T`?  Well `hsDeclHasCusk` reports True
 for the class decl, without even looking at `T`.  This seems wrong.

   What is the CUSK status of `T`?  Apparently `famDeclHasCusk` returns
 True if the enclosing class has a CUSK, but is that right?  There's a
 comment "all un-associated open families have CUSKs" which I don't
 understand.

   Ah... I see from [http://downloads.haskell.org/~ghc/master/users-
 guide/glasgow_exts.html#complete-user-supplied-kind-signatures-and-
 polymorphic-recursion the manual] that we treat open families as CUSK-ish
 by defaulting.  We should have a Note to explain the rules -- or I suppose
 a Note that summarises and points clearly to the manual as the reference.
 But why do we default here? It seems inconsistent with (say) `data T a b =
 ...`. Is it just an arbitrary choice of convenience?  What about `type
 family F (a :: k1 k2) :: *`?

 * `C` has a CUSK, but in `class C (a :: Type) (b :: k)`, I'm not sure how
 we get to know that `k :: Type`.   Yet, without that `C` would not have a
 CUSK.

   I guess that we are defaulting kind variables to `*`?  Well not to `*`,
 because we might have `class C (a :: k1 k2) where ...`

 After typing this in I realise that all I'm seeking is a clearer
 exposition of the CUSK rules.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#comment:17>
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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  merge
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:                    |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Compile-time      |            Test Case:  indexed-
  crash or panic                     |  types/should_compile/T15142
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 The rules are in the
 [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html
 #complete-user-supplied-kind-signatures-and-polymorphic-recursion manual].
 There is also `Note [Complete user-supplied kind signatures]`, but I see
 now that it's a bit out of date. To avoid duplication, I'll just have the
 Note point to the manual.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#comment:18>
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] #15142: GHC HEAD regression: tcTyVarDetails

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#15142: GHC HEAD regression: tcTyVarDetails
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  goldfire
            Type:  bug               |               Status:  closed
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler (Type    |              Version:  8.5
  checker)                           |             Keywords:  TypeInType,
      Resolution:  fixed             |  TypeFamilies, CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Compile-time      |            Test Case:  indexed-
  crash or panic                     |  types/should_compile/T15142
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by bgamari):

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


Comment:

 Merged with d0dfc5cc4859a07778bc674eb865811616d4d6c6.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15142#comment:19>
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
12