This is the evolution of the ideas that have been floating around about domains being an interface, not a type.
I think to support domains from other packages and Base (like IntervalSets, or Set) we should re-structure this package a bit to use traits. That is, we'd have the following:
abstract type DomainStyle end
struct IntervalStyle <: DomainStyle end
struct PointStyle <: DomainStyle end
struct SetStyle{T} <: DomainStyle end
DomainStyle(::Type{<:IntervalSets.Interval}) = IntervalStyle()
DomainStyle(::Type{<:Number}) = PointStyle()
DomainStyle(::Type{<:AbstractArray{T}}) where T = SetStyle{T}()
DomainStyle(::Type{<:AbstractSet{T}}) where T = SetStyle{T}()
I think the best way to implement this proposal is to do this in a separate branch, side-by-side with ApproxFun's adoption of Domains.jl. The result will be that, for example, we can do f = Fun(exp, [1,2,3]) for a function supported on the points [1,2,3] instead of g = Fun(exp, union(Point(1), Point(2), Point(3)), and have the property that domain(f) === [1,2,3]. And also domain(Fun(exp, 1..2)) === 1..2.
This will ease the "wrapper bloat" of trying to make everything a subtype Domain.
This is the evolution of the ideas that have been floating around about domains being an interface, not a type.
I think to support domains from other packages and Base (like IntervalSets, or
Set
) we should re-structure this package a bit to use traits. That is, we'd have the following:I think the best way to implement this proposal is to do this in a separate branch, side-by-side with ApproxFun's adoption of Domains.jl. The result will be that, for example, we can do
f = Fun(exp, [1,2,3])
for a function supported on the points[1,2,3]
instead ofg = Fun(exp, union(Point(1), Point(2), Point(3))
, and have the property thatdomain(f) === [1,2,3]
. And alsodomain(Fun(exp, 1..2)) === 1..2
.This will ease the "wrapper bloat" of trying to make everything a subtype
Domain
.