浮動數字

文字的型別

Prelude> :t 1.0
1.0 :: Fractional a => a

選擇帶註釋的具體型別

你可以使用型別註釋指定型別。唯一的要求是型別必須有 Fractional 例項。

Prelude> 1.0 :: Double
1.0
it::Double
Prelude> 1.0 :: Data.Ratio.Ratio Int
1 % 1
it::GHC.Real.Ratio Int 

如果不是編譯器會抱怨

Prelude> 1.0 :: Int
<interactive>:
    No instance for (Fractional Int) arising from the literal `1.0'
    In the expression: 1.0 :: Int
    In an equation for `it': it = 1.0 :: Int