diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-22 00:51:09 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-22 00:51:09 +0300 |
commit | 993e64759d168522ec70b7c5398182483383d568 (patch) | |
tree | 93aeede2ff12a680cc14ef95116cbe418ca5f327 | |
parent | 7e5482763bea64116a10c047ed87fd67e3a0aaa9 (diff) | |
download | myslip-993e64759d168522ec70b7c5398182483383d568.tar.gz myslip-993e64759d168522ec70b7c5398182483383d568.zip |
doc: added documentation on writing types
-rw-r--r-- | TUTORIAL.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/TUTORIAL.md b/TUTORIAL.md index 9c85478..4ae36db 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -130,6 +130,43 @@ and after it it is too, while in the middle term where `x = 2` is defined, `x = 2`. +Types +----- + +Types are written as seen in the return types in the REPL. +The base types of myslip are +* `Int` for integer +* `Bool` for boolean +* `Nil` for `()` +* `Type` for type literals +* `Let` (what'd be the sensible type if not a special one?) +* `Quote`, `Vector` and `Sum` for use in data structures. +The types used in data structures will be covered later. + +These can be combined using the arrow type, list type and +vector type. + +`(A -> B)` denotes a function with arguments of type `A` +and a return value of type `B`. + +`(A B C D)` denotes a 4-length list with the respective types +at respective positions. Though if it is an actual list not +to be interpreted, in most cases a `Quote` will be present in +the type: `(Quote (A B C D))`. Note that the length of a list +can be any nonnegative integer (within memory constraints), +but it needs to be fixed. + +`(A ...)` denotes a list the length of which is not known and +whose each element is of type `A`. If this is in a vector +structure, `Vector` is prepended as such: `(Vector (A ...))`. + +`(Sum A B)` denotes the type of a coproduct, the left type of +which is `A` and right type `B`. + +Generics have limited support in myslip. +They are written in uppercase. + + Functions --------- |