Closed Bodigrim closed 3 years ago
Sorry for the late response. And thanks you for the great work! This is a feature that I have wanted for a long time but have not been able to implement.
Let's continue on the top level of comments :)
tan
is easy to refactor into tanPrecise
, returning at most two intervals, and Floating.tan
itself. I do not have applications for tan
anyways, so do not mind to follow the suite of signum
and return whole
instead of throw LossOfPrecision
. Then tanPrecise
can be exposed to users who care about it and reused by a potential future instance Floating (IntervalSet a)
.
(**)
is more troublesome. The thing is that sometimes it results in an infinite list of intervals: imagine (-3<..<-2) ** whole
, which consists of all integer powers of (-3<..<-2)
. So even IntervalSet
flexibility is not enough to provide a total function, if we wish to be precise. This is probably a sign to use a convex hull over-approximation as well.
Providing both convex-hull variant and exact-computation variant is a good idea, and I think there are three options for that:
foo
and exact-computation variant as fooPrecise
which throws LossOfPrecision
when the result cannot be expressed as an interval (in the case of Floating Interval
) or a finite union of intervals (in the case of Floating IntervalSet
).fooPrecise
to have more flexible (and non-uniform?) interface (e.g. returning multiple intervals in the Interval
case instead of throwing exception).foo
and a convex-hull variant as (say) fooApprox
. (And change the current behavior of signum
)I personally prefer (1) as an interface for library users but I don't have a strong opinion, so please use the way you think is best.
@msakai I've made both tan
and (**)
total functions, applying a convex hull when needed. How does it look?
@msakai I made two additional changes:
extractSingleton
. I needed it on several occasions, and it is a bit cumbersome to implement on client's side.DivideByZero
from recip
. Mostly because pointwise recip :: Double -> Double
does not throw such error and is very similar in its perceived "totality" to log
, (**)
, etc. This also makes the next release of data-interval
less breaking: at least no function, which used to be total before, starts to explode.If it looks all right to you, it would be nice to make a release at some point soon.
Please merge the PR.
If it looks all right to you, it would be nice to make a release at some point soon.
+1 If you plan to do a release, I leave it to you. If not, I'll do it.
(I pushed a minor clarification to changelog, hopefully it is fine)
@msakai if you have time available, I'll appreciate you making a release.
if you have time available, I'll appreciate you making a release.
Sure.
I added the v2.1.0 tag and uploaded it to Hackage.
This appeared to be much tougher than expected, and I am too exhausted to undertake
instance Floating IntervalSet
.