【发布时间】:2018-02-09 20:23:31
【问题描述】:
来自haskell示例http://learnyouahaskell.com/types-and-typeclasses
ghci> read "5" :: Int
5
ghci> read "5" :: Float
5.0
ghci> (read "5" :: Float) * 4
20.0
ghci> read "[1,2,3,4]" :: [Int]
[1,2,3,4]
ghci> read "(3, 'a')" :: (Int, Char)
(3, 'a')
但是当我尝试时
read "asdf" :: String
或
read "asdf" :: [Char]
我得到异常
Prelude.read No Parse
我在这里做错了什么?
【问题讨论】:
标签: haskell