DEV Community

Discussion on: Bounded types in fp-ts

Collapse
 
iquardt profile image
Iven Marquardt • Edited

I guess you've already recognized the natural number issue with TS. You can only enforce natural numbers or integers at runtime. I work on a type validator where you can write Nat(18) or Int(-18) instead of the number literal. Nat/Int are just subclasses of Number. In order to avoid the performance penalty I intend to erase the Nat(...)/Int(...) pattern during build process. However, frequently writing the constructor calls remains a bit tedious.