小编gdj*_*gdj的帖子

Haskell:使用两个浮动参数的组合函数失败

我试图用类型(Floating a) => a -> a -> a的函数组成一个类型的函数(Floating a) => a -> a来获得类型的函数(Floating a) => a -> a -> a.我有以下代码:

test1 :: (Floating a) => a -> a -> a
test1 x y = x

test2 :: (Floating a) => a -> a
test2 x = x

testBoth :: (Floating a) => a -> a -> a
testBoth = test2 . test1
--testBoth x y = test2 (test1 x y)
Run Code Online (Sandbox Code Playgroud)

但是,当我在GHCI中编译它时,我收到以下错误:

/path/test.hs:8:11:
    Could not …
Run Code Online (Sandbox Code Playgroud)

haskell function-composition

6
推荐指数
1
解决办法
1100
查看次数

标签 统计

function-composition ×1

haskell ×1