What does comparable mean in Elm? -
i'm having trouble understanding comparable
in elm. elm seems confused am.
on repl:
> f1 = (<) <function> : comparable -> comparable -> bool
so f1
accepts comparables.
> "a" "a" : string > f1 "a" "b" true : bool
so seems string
comparable.
> f2 = (<) 1 <function> : comparable -> bool
so f2
accepts comparable.
> f2 "a" infer type of values flowing through program, see conflict between these 2 types: comparable string
so string
is , is not comparable?
why type of f2
not number -> bool
? other comparables can f2
accept?
normally when see type variable in type in elm, variable unconstrained. when supply of specific type, variable gets replaced specific type:
-- says have function: foo : -> -> -> int -- once give value actual type foo, occurences of `a` replaced type: value : float foo value : float -> float -> int
comparable
type variable built-in special meaning. meaning match against "comparable" types, int
, string
, few others. otherwise should behave same. think there little bug in type system, given get:
> f2 "a" infer type of values flowing through program, see conflict between these 2 types: comparable string
if bug weren't there, get:
> f2 "a" infer type of values flowing through program, see conflict between these 2 types: int string
edit: opened issue bug
Comments
Post a Comment