[GHC] #8154: Possible bug in open type familes: Conflicting (a->a) and (a->a->a) instances

GHC ghc-devs at haskell.org
Thu Aug 22 03:34:20 UTC 2013


#8154: Possible bug in open type familes: Conflicting (a->a) and (a->a->a)
instances
----------------------------------------------+----------------------------
        Reporter:  nh2                        |            Owner:
            Type:  bug                        |           Status:  closed
        Priority:  normal                     |        Milestone:  7.8.1
       Component:  Template Haskell           |          Version:  7.7
      Resolution:  invalid                    |         Keywords:  type
Operating System:  Unknown/Multiple           |  families
 Type of failure:  GHC rejects valid program  |     Architecture:
       Test Case:                             |  Unknown/Multiple
        Blocking:                             |       Difficulty:  Unknown
                                              |       Blocked By:
                                              |  Related Tickets:
----------------------------------------------+----------------------------
Changes (by goldfire):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Failure in this case is the desired behavior, which is a change from GHC
 7.6.

 Consider

 {{{
 type family Loop a
 type instance Loop a = Loop a -> Loop a
 }}}

 What should `BoundsOf (Loop Bool)` be? Depending on your type family
 reduction strategy, you could end up choosing either instance in your
 example, which is very bad. If you want a lot more background, check out
 section 6 of [http://www.cis.upenn.edu/~eir/papers/2014/axioms/axioms-
 extended.pdf this draft paper].

 But, it seems that implementing your desired behavior is indeed possible
 with a closed type family:

 {{{
 type family BoundsOf x where
   BoundsOf (a->a) = Int
   BoundsOf (a->a->a) = (Int,Int)
 }}}

 would probably work just fine for most purposes.

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




More information about the ghc-tickets mailing list