Linear types proposal for Hare
View source (Markdown). Basics of linear types The borrow checker is mostly based on the concept of linear types. In short: values of linear types must be used once and cannot be copied. They represent finite resources (for example, files). There are also free types, which are building blocks for linears and, unlike the other kind, can be copied. These are scalar types like i32 or bool. In the standard view of linear types, any function that does operations with an object must use the object and return it back, leading to the following API: linear type file = …; fn open(path: str) file = …; fn write(f: file, data: []u8) file = …; fn close(f: file) void = …; This is not always great, since write can return a completely different file or modify its internal representation. This can…