[GHC] #15592: Type families without CUSKs cannot be given visible kind variable binders

GHC ghc-devs at haskell.org
Mon Sep 3 12:56:01 UTC 2018


#15592: Type families without CUSKs cannot be given visible kind variable binders
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.4.3
      Resolution:                    |             Keywords:
                                     |  TypeApplications, TypeFamilies,
                                     |  CUSKs
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 I agree with comment:1. If a user writes the name of the variable, it is
 `Specified`. Thus, `a` is specified (in both declarations). `k`,
 unmentioned, is `Inferred`.

 But I see some trouble ahead.

 Consider

 {{{#!hs
 data VisProxy k (a :: k) = MkVP
 class D (a :: Proxy j) (b :: Proxy k) c where
   meth1 :: forall z. D @j @k a b z => z -> Proxy '(a, b)
   meth2 :: Proxy k j -> Proxy '(a, b, c)
 }}}

 The constraint in `meth1` looks like it's redundantly specifying that `D`
 should be instantiated at `j` and `k`. I say "redundantly" because `D`,
 without a CUSK, cannot be polymorphically recursive. However, we discover
 in `meth2` that `j` actually depends on `k`. So (assuming inference
 succeeds at all, which I don't wish to debate here), we will get `D ::
 forall (k :: Type) (j :: k). Proxy j -> Proxy k -> Type -> Constraint`.
 (The `Type` in the third required argument to `D` comes from `z`'s kind in
 `meth1`.)

 Bottom line: any use of visible kind application should be considered to
 be an instance of polymorphic recursion, and thus should be banned in a
 mutually recursive group on a CUSK-less type. This is true even if the
 visible kind application is redundant.

 Do you agree?

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


More information about the ghc-tickets mailing list