diff options
Diffstat (limited to 'content/zettel/2a1.md')
-rw-r--r-- | content/zettel/2a1.md | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/content/zettel/2a1.md b/content/zettel/2a1.md new file mode 100644 index 0000000..8ad4419 --- /dev/null +++ b/content/zettel/2a1.md @@ -0,0 +1,35 @@ ++++ +title = "Nominal Typing" +author = "Yann Herklotz" +tags = [] +categories = [] +backlinks = ["2a"] +forwardlinks = ["2ab"] +zettelid = "2a1" ++++ + +Distinguish types by their names. For example, an `Integer` could be a +`Count` or an `Offset`. Operations based on those types should interact +in a different way. This is different to structured typing ([\#2ab]), +which bases the difference of the type not on the name, but the +structure. For example [^1]: + +- `Count` + `Count` is valid, and should give a `Count`. +- `Offset` + `Count` is also likely valid, and will give an `Offset`, + because we can have an `Offset` and some count from a previous + value, and offset by the amount and the count of that object. The + new offset is likely to be valid as well. +- `Count` + `Offset` should probably not be valid, because it is maybe + expected that it returns a `Count`, which would however not be valid + (adding a count and an offset does not anything). However, to keep + associativity, it might make sense to allow this and return an + `Offset` in that case. +- `Offset` + `Offset` should not be valid, because this would allow us + to add offsets which may lead to a new offset that is out of range, + meaning we could access memory that is not valid. + +[^1]: Lelechenko, Andrew. *Haskell for mathematical libraries*. lambda + DAλS talk (13-14 Feb 2020). Kraków, Poland. \[Online\] + <https://www.youtube.com/watch?v=qaPdg0mZavM>. + + [\#2ab]: /zettel/2ab |