.hs 代码:
data Person = Person { firstName :: String
, lastName :: String
, age :: Int
} deriving (Eq, Show, Read)
编译:
*Main> :load "/home/optimight/baby.hs"
[1 of 1] Compiling Main ( /home/optimight/baby.hs, interpreted )
Ok, modules loaded: Main.
在编译后立即测试时:
*Main> read "Person {firstName = \"Michael\", lastName \"Diamond\", age = 43}" :: Person
*** Exception: Prelude.read: no parse
请指导。为什么会发生此错误以及如何避免此类错误?