[GHC] #10532: Unnecessary constraints when using overlapping instances

GHC ghc-devs at haskell.org
Tue Jun 16 18:57:06 UTC 2015


#10532: Unnecessary constraints when using overlapping instances
-------------------------------------+-------------------------------------
        Reporter:  MikeIzbicki       |                   Owner:
            Type:  bug               |                  Status:  closed
        Priority:  normal            |               Milestone:
       Component:  Compiler (Type    |                 Version:  7.10.1
  checker)                           |                Keywords:
      Resolution:  invalid           |            Architecture:
Operating System:  Unknown/Multiple  |  Unknown/Multiple
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by MikeIzbicki):

 I understand the differences between `-XOverlappingInstances` and
 `-XIncoherentInstances`, and my question is not about that.  My question
 is just about syntax.

 Without `-XOverlappingInstances`, GHC interprets the types `a -> Int` and
 `Foo a => a -> Int` as the same thing.  Whenever you can use one, you can
 also use the other (at least in all the cases I tried).  But without
 overlapping instances, GHC no longer interprets these types the same way.
 Only the second type is valid for `f`, but I would rather write the first
 type because I know GHC can find an instance `Foo` for all `a`.  The
 particular instance will depend on the weird interactions caused by
 overlapping instances, but there's guaranteed to be an instance available.

 My question is: Why is this syntactic difference useful?  Maybe
 parametricity would be broken without it?

 ----

 Even if this syntactic difference is useful, I still think there is a GHC
 bug.  Consider what happens in the overlapping instances case when you
 omit the type signature for `f = foo`.  GHC infers the type `a -> Int`,
 but then complains that the class constraint `Foo` can't be found.  GHC
 should instead infer the type `Foo a => a -> Int`, which would let us omit
 the type signature.

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


More information about the ghc-tickets mailing list