Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我在 Haskell 中使用 floor 时,即 floor 1.7 我认为它会给我 1 并且它的类型将是 Int 但我不断收到一条错误消息,好像不是这种情况?
对我来说很好:
ghci > floor 1.7 1 ghci > :t floor floor :: (Integral b, RealFrac a) => a -> b
您可以通过明确提及类型来强制它成为Int类型:
Int
ghci > floor 1.7 :: Int 1
或者如果你想要Integer,
Integer
ghci > floor 1.7 :: Integer 1