【发布时间】:2016-03-13 14:25:25
【问题描述】:
我尝试组合两个指定类型的函数。
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
任何想法为什么我会得到这个?
【问题讨论】:
标签: haskell function-composition