
7 Jun
2013
7 Jun
'13
6:42 a.m.
Hi all, In ghci, let us type:
data Worker x y = Worker x y deriving Show let a = Worker 2 3.4 :t a a :: Worker Integer Double
According to which procedure does ghci chooses Integer for 2, and Double for 3.4? I believed that in such a case I was compelled to indicate a type signature explicitly, for example:
let a = Worker (2::Int) (3.4::Float) :t a a :: Worker Int Float
I knew that numbers in Haskell are polymorphic constants instances of the Num typeclass:
:t 2 2 :: Num a => a
But what is happening exactly when he chooses Integer and Double above? Thanks in advance, TP