I\'m having trouble understanding what exactly a comparable
is in Elm. Elm seems as confused as I am.
On the REPL:
> f1 = (<)
&l
I think this question can be related to this one. Int
and String
are both comparable
in the sense that strings can be compared to strings and ints can be compared to ints. A function that can take any two comparables would have a signature comparable -> comparable -> ...
but within any one evaluation of the function both of the comparables must be of the same type.
I believe the reason f2
is confusing above is that 1
is a number
instead of a concrete type (which seems to stop the compiler from recognizing that the comparable must be of a certain type, probably should be fixed). If you were to do:
i = 4 // 2
f1 = (<) i -- type Int -> Bool
f2 = (<) "a" -- type String -> Bool
you would see it actually does collapse comparable
to the correct type when it can.