我是Haskell初学者,有一个奇怪的问题.到目前为止,一切都很顺利,我已经能够正常使用Prelude读取功能.现在突然我必须不断声明它的类型才能使用它.
我总是要声明这个或类似的东西才能使用它.
let r = read::String-> Int
Run Code Online (Sandbox Code Playgroud)
我已经尝试重新启动ghci,因为我不小心重载了读取,但每当我尝试正常使用它时
read "456"
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
No instance for (Read a0) arising from a use of `read'
The type variable `a0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Read () -- Defined in `GHC.Read'
instance (Read a, Read b) => Read (a, b) -- Defined in `GHC.Read'
instance (Read a, Read b, Read c) => Read (a, b, c)
-- Defined in …Run Code Online (Sandbox Code Playgroud)