[GHC] #12088: Type/data family instances in kind checking

GHC ghc-devs at haskell.org
Mon Feb 6 17:19:58 UTC 2017


#12088: Type/data family instances in kind checking
-------------------------------------+-------------------------------------
        Reporter:  alexvieth         |                Owner:
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.1
       Component:  Compiler (Type    |              Version:  8.1
  checker)                           |
      Resolution:                    |             Keywords:  TypeInType
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #11348, #12239    |  Differential Rev(s):  Phab:D2272
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 The nub of my idea in comment:13 and comment:15 is this:

 * Track dependency on ''declarations'' independently from ''definitions''.

 * When `T`'s declaration depends on `S`'s declaration, then `T`'s
 definition depends on `S`'s definition.

 * Dependency tracking is, as usual, transitive.

 So in the smaller example in comment:35, `F`'s declaration depends on
 `Open`'s. So `F`'s definition -- the instances -- depends on `Open`'s.
 This means we type check `Open`'s instances before `F`'s. There's lots
 more detail (comment:15) but this is the basic idea.

 Here is a case (due to Iavor) that would be rejected:

 {{{
 type family Open a
 type instance Open Int = Bool
 type instance Open Char = F FLoat
 type instance Open Float = Type

 type family F a :: Open a
 type instance F Int = True
 type instance F Char = [True]
 type instance F Float = [Bool]
 }}}

 The instances for a given type family are checked as a clump, and these
 instances can be accepted only by interleaving.

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


More information about the ghc-tickets mailing list