【发布时间】:2015-05-14 07:04:10
【问题描述】:
我已经定义了一个函数:
gen :: a -> b
所以只是尝试提供一个简单的实现:
gen 2 = "test"
但抛出错误:
gen.hs:51:9:
Couldn't match expected type ‘b’ with actual type ‘[Char]’
‘b’ is a rigid type variable bound by
the type signature for gen :: a -> b at gen.hs:50:8
Relevant bindings include gen :: a -> b (bound at gen.hs:51:1)
In the expression: "test"
In an equation for ‘gen’: gen 2 = "test"
Failed, modules loaded: none.
所以我的功能不正确。为什么a 没有输入为 Int 而b 没有输入为 String ?
【问题讨论】:
标签: haskell