The Third Bit: An E-Bike for the Mind

Speaking of which, do any of my programming language friends know of a type system that captures "how it's used" as opposed to "what values it's allowed to have" in the way that Sajaniemi's variable roles do? Borrow checking in Rust is kind of somewhat adjacent, but not really the same thing - any others?

@gvwilson Wouldn‘t an „Iterator“ type fit that description? A couple of languages have those.

Swift has a few more types that go in that direction of „how it‘s used“ but often not on the same level of simplicity as in Sajaniemi‘s variable roles.

Here are some that I think go in that direction and that exist in Swift:

- Sequence and Collection: protocols in Swift
- ~Copyable: a value that cannot be copied, so a move-only type: only one object can hold onto it at a time
- Mutex: used to wrap other values in it, to prevent concurrent access/modification of the wrapped value in a concurrent program
- actor: a keyword-level type in Swift. Used to protect state and then „act“ on it in a concurrency-safe manner. Some parallels to Mutex, but a lot more complexity around it. Ensures modifications to the state are serialized (instead of happening concurrently) but doesn‘t block like a Mutex.
- the `let` keyword basically captures the „fixed value“ concept. However there are subtle differences between using it for value types and for reference types.
- the Result type holds the result of a computation that may have gone wrong