这是一个显示问题的小程序:
import Data.Fixed
main = do
print x
where
x :: Pico
x = read "12" -- error: no instance for 'Read Pico'我在Fixed.hs中看到了库GHC的源代码--有一个用于读取(复制一些代码)的实例:
type Pico = Fixed E12
data E12 = E12
instance HasResolution E12 where
resolution _ = 1000000000000
instance (HasResolution a) => Read (Fixed a) where
readsPrec _ = readsFixed我的推理出了什么问题?为什么编译器看不出Pico是Read的实例?
发布于 2012-03-24 17:53:40
已修复从基础4.4.0.0开始的读取实例,即GHC 7.2。您可能有一个较旧的版本。
https://stackoverflow.com/questions/9850690
复制相似问题