我尝试用类型指定组合两个函数。
foo :: Num a => a -> a
foo a = a + 2
bar :: Num a => a -> a
bar a = a * 2
fooBarCompose :: (Num a, Num b, Num c) => (a -> b) -> (c -> a) -> c -> b
fooBarCompose f g = f . g
我的模块编译,但在运行时调用
fooBarCompose bar foo
我收到错误:
No instance for (Show (b0 -> b0))
(maybe you haven't applied enough arguments to a function?)
arising from a use of ‘print’
In the first argument of ‘print’, namely ‘it’
In a stmt of an interactive GHCi command: print it
为什么我得到这个?
答案 0 :(得分:11)