小编hNe*_*ewb的帖子

刚性类型变量错误

这个功能有什么问题?

test :: Show s => s
test = "asdasd"
Run Code Online (Sandbox Code Playgroud)

String是Show类的一个实例,所以看起来是正确的.

错误是

src\Main.hs:224:7:
    Couldn't match expected type `s' against inferred type `[Char]'
      `s' is a rigid type variable bound by
          the type signature for `test' at src\Main.hs:223:13
    In the expression: "asdasd"
    In the definition of `test': test = "asdasd"
Run Code Online (Sandbox Code Playgroud)

haskell

32
推荐指数
2
解决办法
1万
查看次数

标签 统计

haskell ×1