When I enter :t
command in GHCi I see polymorphic type:
ghci> :t 42
42 :: Num t => t
ghci> :t div
div :: Integral a => a -> a -> a
But after I actually evaluate such functions I see result of type defaulting rules. Is there some command or ability to observe in ghci how type will be changed after type defaulting rules applied according to Haskell report and/or ghc implementation?
Since GHC 8.4.1 it's possible to use :type +d
(or :t +d
for short) option to print the type of an expression, defaulting type variables if possible.
ghci> :t 42
42 :: Num p => p
ghci> :t +d 42
42 :: Integer
ghci> :t div
div :: Integral a => a -> a -> a
ghci> :t +d div
div :: Integer -> Integer -> Integer