小编cr0*_*IAN的帖子

Haskell Read(无实例)

我是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)

haskell overloading instance ghci

5
推荐指数
2
解决办法
2450
查看次数

标签 统计

ghci ×1

haskell ×1

instance ×1

overloading ×1