GHC mistakenly warns about type defaulting in the presence of -XTypeApplications
This code:
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Main (main) where
theFloatDigits :: forall a. RealFloat a => Int
theFloatDigits = floatDigits (undefined @_ @a)
main :: IO ()
main = print (theFloatDigits @Double, theFloatDigits @Float)
erroneously produces this warning:
$ /opt/ghc/8.0.1/bin/runghc -Wall TheFloatDigits.hs
TheFloatDigits.hs:6:19: warning: [-Wtype-defaults]
• Defaulting the following constraint to type ‘Double’ RealFloat a0
• In the ambiguity check for ‘theFloatDigits’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature:
theFloatDigits :: forall a. RealFloat a => Int
(53,24)
GHC's claim that a0 was defaulted to Double is clearly bogus, since theFloatDigits outputs different answers for Double and Float.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | goldfire |
| Operating system | |
| Architecture |