I wasn’t suggesting anything concrete - jusy musing on an old idea I never quite got working.
The main interpretation of a negative interval was as a negative (higher-kinded) number and then treated as a negative space (in my case). A mask over the interval was the practical idea, so interval 2 3 + interval 0 4 = interval 0 4 interval 2 3 + interval 4 0 = interval 4 0 in a convex hull union interpretation. I didn’t imply that code needs changing. I couldn’t quite make it work.
The main reason for my numhask-space library is to accomodate higher-kinded intervals, aka a rectangle composed of two intervals (interval 2 3, interval 0 4) and then unoin to calculate bounding rectangles (convex hulls) on 2d shapes for a chart library.
A point or a surface doesn’t have a valid ord instance - you need a lattice approach - which is heading towards a pretty esoteric requirement.
The main idea I had with the interval-patterns api is whether you could use left and right associated operators, so
So union (2 :||: 5) (5 :<>:7) becomes
⟦2 5⟧ ∪ ⟪5 7⟫ = ⟦2 7⟫
The symbols attach to the numbers ⟦2 5⟧ is function application and hence a blank.
Mixfix (heehee) operators are hard to do in Haskell, which is why I stuck with infix ((:||:) and friends). It would be interesting to see this design space explored, but I think even with -XPostfixOperators you would need parentheses like ⟦ 2 (5 ⟧) to be able to express them properly.
Interesting idea. Reminds me of bra-ket notation in physics. Perhaps we can interpret ⟦2 as an idempotent function, for example max 2. Likewise, 5⟧ would be min 5. The final convex set is then obtained by applying the chain of functions to Whole, just like what ShowS does.
The idea of describing points or sets by iterated functions is not new, of course. It is the basis of Conway’s surreal numbers and of signed-digit exact reals. There, the basic functions (digits) are certain contractions, represented as mid-pointing with a dyadic number.
By the way, Escardo and Simpson have a paper where they exhibit the closed real interval as the free mid-point algebra over two points. You might find that interesting. More general version here.