HN2new | past | comments | ask | show | jobs | submitlogin

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:

https://github.com/microsoft/TypeScript/issues/43505



Is this equivalent to open intervals e.g. (0, null)?


It would just be the type `(>0)`




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: