我有以下功能:没有实例(NUM(INT - >智力)),从字面'5' 产生
f :: (Int -> Int) -> Int
f = undefined
现在我想打电话给f
与5
(这是不正确的):
f 5
显然,这不应该编译,因为5
是不是从Int
到Int
功能。 所以,我期待一个错误消息,如Couldn't match expected type Int -> Int with Int
。
而是我得到:
No instance for (Num (Int -> Int)) arising from the literal `5'
In the first argument of `f', namely `5'
In the expression: f 5
In an equation for `it': it = f 5
为什么Num
出现在这里?
函数的主体是什么? – Shoe
@J无所谓。增加了“未定义”。 – ZhekaKozlov