Required API functions

Each package creating a new ThickNumber subtype must implement:

ThickNumbers.lovalFunction
loval(x::ThickNumber)

The value representing the lower limit of the span of x. loval must be implemented by any subtype of ThickNumber.

Examples

julia> loval(Interval(1, 2))    # suppose Interval{T} <: ThickNumber{T}
1
source
ThickNumbers.hivalFunction
hival(x::ThickNumber)

The value representing the upper limit of the span of x. hival must be implemented by any subtype of ThickNumber.

Examples

julia> hival(Interval(1, 2))    # suppose Interval{T} <: ThickNumber{T}
2
source
ThickNumbers.basetypeFunction
basetype(::Type{TN}) where TN<:ThickNumber

Strip the valuetype from TN.

Interface requirements

basetype must be implemented by all ThickNumber subtypes.

Examples

In a package implementing Interval you would define

ThickNumbers.basetype(::Type{Interval{T}}) where T = Interval
ThickNumbers.basetype(::Type{Interval}) = Interval

so that

julia> basetype(Interval{Float64})
Interval

This can be used to construct valuetype-agnostic ThickNumbers:

julia> lohi(basetype(Interval{Float64}), 1, 2))
Interval{Int64}(1, 2)
source

If possible, you should also implement:

ThickNumbers.lohiFunction
lohi(::Type{TN}, lo, hi) where TN<:ThickNumber

Construct a TN from its lo and hi values.

Interface requirements

lohi must be implemented by all ThickNumber subtypes.

If

x = lohi(TN, lo, hi)

succeeds without throwing an error, then it is required that

typeof(x) <: TN
lo ∈ x
hi ∈ x
lo ≈ loval(x)
hi ≈ hival(x)

For the latter two, exact equality is not required; this allows for roundoff error (in case TN is parametrized by something other than its lo and hi values) as well as outward rounding for ThickNumber types that aim to be conservative and guarantee acccuracy even in the presence of roundoff error.

source

If your ThickNumber subtype can't be constructed this way, you will likely have to specialize several of the ThickNumber API functions to compensate.

You also need to implement any binary arithmetic operations (a + b, a - b, a * b, a / b). Unary + and - (i.e., -x) have default implementations for all ThickNumber subtypes, although you can choose to specialize if warranted.