相关疑难解决方法(0)

"未定义"如何在Haskell中起作用

我很好奇Haskell中的'undefined'值.它很有趣,因为你可以把它放在任何地方,而Haskell会很开心.以下都是好的

[1.0, 2.0, 3.0 , undefined]  ::[Float]
[1, 2 ,3 undefined, 102312] :: [Int]
("CATS!", undefined)  :: (String, String)
....and many more
Run Code Online (Sandbox Code Playgroud)

未定义的工作如何在引擎盖下工作?什么使得拥有每种数据类型的数据成为可能?我可以定义一个这样的值,我可以放在任何地方,或者这是一个特例?

haskell undefined

23
推荐指数
2
解决办法
4435
查看次数

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
查看次数

标签 统计

haskell ×2

function-composition ×1

undefined ×1