Exception: Prelude.read: no parse
更新日期:
文章目錄
1 | solveRPN' :: (Num a, Read a) => String -> a |
By default, the ghc will deduce this function as (Num Int, Read Int)
. The error is casued by the Prelude.read function which cannot parse a “Floating number string” into Int. However, we can explicity specific the type of expression is Float. Integer string can be parsed into Floating number but Floating number cannot be parsed into Int.
1 | read "4.0" :: Int |