【发布时间】:2015-08-07 19:54:39
【问题描述】:
我无法理解 Elm 中的 comparable 到底是什么。 Elm 似乎和我一样困惑。
在 REPL 上:
> f1 = (<)
<function> : comparable -> comparable -> Bool
所以f1 接受比较。
> "a"
"a" : String
> f1 "a" "b"
True : Bool
所以看起来String 是可比的。
> f2 = (<) 1
<function> : comparable -> Bool
所以f2 接受一个可比较的。
> f2 "a"
As I infer the type of values flowing through your program, I see a conflict
between these two types:
comparable
String
所以String 是和不是可比的?
为什么f2 的类型不是number -> Bool? f2 还可以接受哪些其他可比对象?
【问题讨论】:
标签: elm