Update spec.md

This commit is contained in:
2025-09-15 21:42:29 +02:00
parent c5d85ad7e9
commit ecc037415b

39
spec.md
View File

@@ -21,6 +21,29 @@ One of:
- `'Case1 t1 | 'Case2 t2 | ...?Identifier`: partial tagged union type, `Identifier`
- `{field1: xt, field2: yt, ...?Identifier}`: partial non-nominal record type, `Identifier`
## Generic types
Means that the structure of that value is not available at compile time.
This implies that you can dispatch on those values.
This means that you can not write a magic `List.toString` function, because you would have to dispatch on `toString`,
so you have to do something like this:
```
def List.toString =
toStr: (t -> Char List) ->
list: t List ->
...
```
This is also the case for equality, and `List.contains`:
```
def List.any =
fn: (t -> Bool) ->
list: t List ->
...
List.any(x -> x = y, list)
```
## Recursive types
Recursive / self-referential types
@@ -68,9 +91,6 @@ type Uint8 = {...?Uint8}
</details>
## Syntax
TODO ebnf
## Compatible-with
Check if type is compatible-with / assignable-to type requirements.
@@ -390,6 +410,19 @@ Give fuzzy-matched suggestions for at the following things:
# Syntax
Note that the order of syntax cases matter!
```
Identifier = { (* ( a-z | A-Z | 0-9 | _ | - | . | # ) TODO: cvt to ebnf *) };
Partial Type = '?', Identifier;
Union Type Case = '\'', Identifier, [ Type (*default to Unit*) ];
Union Type = Union Type Case, { '|', Union Type Case};
Record Type Field = Identifier, ':', Type;
Record Type = '{', [Record Type Field, {',' Record Type Field }], [ '...', Partial Type ], '}';
Type = Partial Type | Identifier | Union Type | Record Type | TODO;
```
# OLD SPECIFICATION STARTING HERE
## automatic return types
```