This pull request implements changes to IntersectionDomain and DifferenceDomain so that they also support domain-like types, and adds some tests for this case.
The union function is only extended for actual Domain types. Domainlike types can only be grouped by explicitly invoking the UnionDomain constructor, because we can't hijack union with duck typing in this package.
I looked into making the domains in UnionDomain into a Set, but there is a tradeoff: the Set would preserve types only if all domains have the same type. Currently, since the domains field can be a tuple, it is at least possible to preserve all type information. The disadvantage is that a large union will be demanding for the compiler, presumably.
Todo: do performance tests on the constructor and, if necessary, make some special cases more efficient.
This pull request implements changes to
IntersectionDomain
andDifferenceDomain
so that they also support domain-like types, and adds some tests for this case.The
union
function is only extended for actualDomain
types. Domainlike types can only be grouped by explicitly invoking theUnionDomain
constructor, because we can't hijackunion
with duck typing in this package.I looked into making the domains in
UnionDomain
into aSet
, but there is a tradeoff: theSet
would preserve types only if all domains have the same type. Currently, since thedomains
field can be a tuple, it is at least possible to preserve all type information. The disadvantage is that a large union will be demanding for the compiler, presumably.Todo: do performance tests on the constructor and, if necessary, make some special cases more efficient.