I took the idea of interval types and decomposed them to an even lower primitive: Inequality types. An interval type is just an intersection of two inequality types. For example `(>0) & (<1)` is the interval `(0, 1)`. You can read this as "a number being larger than 0 and smaller than 1". `(<1)` is also valid, which is "a number smaller than 1" as a type.
The nice thing about this decomposition is that applying arithmetic "just works" because you just define them for the inequality primitive.
I prototyped this for TypeScript and created a proposal. It does not contain type-level arithmetic because TS doesn't do that kind of type-level stuff in general. I'm not entirely convinced myself of that proposal, but maybe someone finds this interesting:
The nice thing about this decomposition is that applying arithmetic "just works" because you just define them for the inequality primitive.
I prototyped this for TypeScript and created a proposal. It does not contain type-level arithmetic because TS doesn't do that kind of type-level stuff in general. I'm not entirely convinced myself of that proposal, but maybe someone finds this interesting:
https://github.com/microsoft/TypeScript/issues/43505