... > Also, the domain should define how to compare objects and could provide > details about whether the set is finite, countable or uncountable. ...
Sounds like a role "Domain" that provides methods (off the top of my head)- ordering - returns Nil if the domain is unordered, or a method implementing "cmp" if it is ordered succ, pred- returns Nil if the domain is uncountable, or method implementing "next item", "prior item" if countable. count - returns Inf if it's an infinite domain, or count of objects if finite. What if counting is an expensive operation? perhaps there should also be an "is_infinite" method that returns true or false. Then the .. operator can accept anything that does Domain where ordering is non-Nil, and the ... operator can add the condition that succ/pred are non-Nil.