[GHC] #11947: GHC mistakenly warns about type defaulting in the presence of -XTypeApplications

GHC ghc-devs at haskell.org
Mon Apr 18 14:56:19 UTC 2016


#11947: GHC mistakenly warns about type defaulting in the presence of
-XTypeApplications
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.0.1
  checker)                           |             Keywords:
      Resolution:                    |  TypeApplications
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect         |  Unknown/Multiple
  warning at compile-time            |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Replying to [comment:3 goldfire]:
 > `theFloatDigits` isn't the thing that's ambiguous or not; it's
 `theFloatDigits`'s type, `forall a. RealFloat a => Int`, which certainly
 is ambiguous, mentioning a type variable only in a constraint and not the
 type head.

 Sorry, I was confused. You're absolutely right in that `theFloatDigits`'s
 type signature is ambiguous. That is apparent if you try to typecheck
 something similar without defaulting rules like:

 {{{#!hs
 theIsSigned :: forall a. Bits a => Bool
 theIsSigned = isSigned (undefined @_ @a)
 }}}

 This fails to compile without `-XAllowAmbiguousTypes` enabled, which makes
 sense.

 `theFloatDigits`, on the other hand, compiles both with and without
 `-XAllowAmbiguousTypes`! This adds another wrinkle to the bug—should it
 require `-XAllowAmbiguousTypes`, or should it type defaulting make certain
 otherwise-ambiguous type signatures permissible?

 I'm not sure what the answer is, but I do believe that we should at least
 have some way to write `theFloatDigits` without needing to disable
 `-Wtype-defaults` altogether. Would it make sense to disable type
 defaulting in ambiguity checks when `-XAllowAmbiguousTypes` is enabled?
 After all, the warning message already suggests turning it on.

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


More information about the ghc-tickets mailing list