6 ms·
I pretty sure the poster meant the general 'fraction' (quotient) construction (set 'a' is like set 'b' but with certain elements to be regarded as the same - 'a
by jan_Inkepa 6y ago
I pretty sure the poster meant the general 'fraction' (quotient) construction (set 'a' is like set 'b' but with certain elements to be regarded as the same - 'a rational number is a pair of numbers, where you regard (ax,ay) to be the same as (x,y)'. ), rather than rational numbers exactly. (Similarly, Actionscript 3 had generic lists, but not generic types generally IIRC).
- dragonwriter 6y agoIsn't this usually trivial to inplement, but pointless because you'll never want to abstract over it? It's basically a type characterized by a base type and a canonicalization function that maps all values in that type to a subset of the same type, with those values that have the same canonicalized value being equal.
- jacobolus 6y agoIn order to deal with quotients it is not necessary to normalize to a single representative for each equivalence class (though sometimes that can be useful). The more important part is a facility for detecting whether two objects are equivalent, and a guarantee that all other operations respect the structure.
- dragonwriter 6y ago> In order to deal with quotients it is not necessary to normalize to a single representative for each equivalence class I may have been thinking about too close of an analogy with mathematical quotients where there are other operations and you are going to want to apply those to the canonical form generally, but, sure, I can see that. My point was in languages where you can construct user-defined generics types, a general implementation is usually straightforward but not particularly useful, because it's an abstraction you'd almost never consume except in defining concrete types. General operations on quotient-like types aren't something that there is much call for. And I think that's just as true with or without canonicalization. I would suspect that that is why, unlike say iterables (or in languages with more powerful type systems, monads) it's not something you see supported out of the box in type systems.
- deleted 6y ago[deleted]
- alanbernstein 6y agoI'm not sure what distinction you're making? https://docs.python.org/3/library/fractions.html https://docs.python.org/3/library/fractions.html
- germanier 6y agoThe same but for non-numbers.
- alanbernstein 6y agoAh, sure. What use might that have?