I suppose it's reasonable to have a defined ordering within a particular class 
e.g. number class includes integers and floats, and have some (possibly 
undefined) ordering between classes. This basically is the same as Erlang term 
order, but for every struct we could define its own class or in some special 
cases a few structures would map to the same ordering class.

Then to make Erlang term ordering to work for us we can build a tuple {{class, 
class_ordering_term}, original_term}, e.g {{Number, 1}, 1}, {{DateTime, 
epoch_integer}, %DateTime{...}}, {{Atom, nil}, nil}.

On 18 October 2019 9:27:54 am AEDT, "José Valim" 
<jose.va...@plataformatec.com.br> wrote:
>> I do wonder about your follow-up: Why would it not work for integers?
>(and
>> float and decimals)? At least as long as we are comparing collections
>of
>> *only* integers or *only* floats or *only* decimals, the result would
>be
>> sensible.
>>
>If we want to make Ordered work between them, well, then it becomes a
>bit
>> more difficult: In that case we probably would need to 'upcast' all
>of them
>> into some kind of more general tuples-of-integers-and-strings form.
>>
>
>Exactly. That's the problem and at a quick glance I could not find a
>solution. I am glad to be proven wrong though!
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "elixir-lang-core" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to elixir-lang-core+unsubscr...@googlegroups.com.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4Kd_E_WMB0iKfR%3DoKGvK6Nq8MJVYVf8tsJ%3DP6vXX1ZT_Q%40mail.gmail.com.

-- 
Kind regards,
Dmitry Belyaev

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CF75C266-8373-4461-AAED-6E8A2FAA9E8C%40gmail.com.

Reply via email to