Loading a = 2+2.0
from a .hs
file in GHCi and doing :t a
shows a :: Double
.
On the other hand, doing let b = 2+2.0
and :t b
in GHCi shows b :: Fractional a => a
.
How are you able to deduce this from these two documents?
- 4.3.4 Ambiguous Types, and Defaults for Overloaded Numeric Operations https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-750004.3
- 2.4.8 Type defaulting in GHCi: https://downloads.haskell.org/~ghc/7.8.3/docs/html/users_guide/interactive-evaluation.html
I find this official documentation almost incomprehensible.