4 ms·
Coming from traditional statically typed languages (Java, C++, Typescript, even Python or Ruby...), you might think of a type like "int" or "Float". He's callin
by pugio 5y ago
Coming from traditional statically typed languages (Java, C++, Typescript, even Python or Ruby...), you might think of a type like "int" or "Float". He's calling stamps "micro-types" because they're more fine-grained than that. A stamp might tag a value as being between 0 and 255, for example, which is much more specific than "int".
It would be really cool to work with a language that allows the user such fine-grained types, which is one reason I keep eyeing Idris.
- jhgb 5y ago> A stamp might tag a value as being between 0 and 255, for example, which is much more specific than "int". Yeah, that's a normal type. For example in Common Lisp, it's the type defined by the type specifier (INTEGER 0 255).
- chrisseaton 5y agoA simple range is one application you could use stamps for, but they can also represent that individual bits may or may not be set, or could even represent that individual bits are set with a given probability, which could inform scheduling decisions.
- jhgb 5y agoThose things can in principle be expressed with a predicate using the SATISFIES type specifier, but the problem with that is that you currently can't pick such types apart for optimization purposes in any existing implementation, only test membership for values. Presumably that's one of the reasons why Qi/Shen was created.
- brundolf 5y agoTypeScript can... sort of do that. They could definitely take it further if they wanted to For example a type could be `0 | 1 | 2 | 3 | 4 | 5`, though there's no way right now to specify that as `0..5`
- CorrectHorseBat 5y agoAda can do that