整數數字

文字的型別

Prelude> :t 1
1 :: Num a => a

選擇帶註釋的具體型別

只要目標型別為帶有註釋的 Num,你就可以指定型別 :

Prelude> 1 :: Int
1
it::Int
Prelude> 1 :: Double
1.0
it::Double
Prelude> 1 :: Word
1
it::Word

如果不是編譯器會抱怨

Prelude> 1 :: String

<interactive>:
    No instance for (Num String) arising from the literal `1'
    In the expression: 1 :: String
    In an equation for `it': it = 1 :: String