我不太理解在Elm中
在REPL中:
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
还可以接受哪些可比较的对象?
comparable
可以在这里找到:https://package.elm-lang.org/packages/elm/core/latest/Basics#compare - Charlie