[GHC] #11621: GHC doesn't see () as a Constraint in type family

GHC ghc-devs at haskell.org
Wed Dec 5 23:24:12 UTC 2018


#11621: GHC doesn't see () as a Constraint in type family
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  7.10.1
  checker)                           |             Keywords:
      Resolution:                    |  ConstraintKinds
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #11715, #13742    |  Differential Rev(s):  Phab:D5413
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 I wish it was really fixed, but it isn't.  Try this
 {{{
 type family F2 b where
   F2 'True  = ()
   F2 'False = NotFound
 }}}
 That elicits
 {{{
 T11621.hs:12:14: error:
     * Expected a type, but `NotFound' has kind `Constraint'
     * In the type `NotFound'
       In the type family declaration for `F2'
    |
 12 |   F 'False = NotFound
    |              ^^^^^^^^
 }}}
 GHC is generally very good about being robustly order-independent; nothing
 depends on the order in which the type inference engine encounters code.
 But this is a rare counter example.  The hack is described in `Note
 [Inferring tuple kinds]` in `TcHsType`.

 In `F`, GHC sees `NotFound` first, and that tells it that the answer is
 `Constraint`.  IN `F2` it sees `()` first and guesses (wrongly) `*`.

 So I would say not-fixed.

 I can think of ad-hoc ways to fix this -- such as having a built-in
 constraint `TK k` which means `k` must be either `*` or `Constraint`.  But
 I have thus far lacked the time and energy to think it through enough or
 implement it.  Especially since #11715 is still open.

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


More information about the ghc-tickets mailing list