v0.0.5: recursive / self-referential types

This commit is contained in:
2025-09-12 10:33:34 +02:00
parent 7e867f684f
commit 52fe4da3b7

19
spec.md
View File

@@ -132,6 +132,11 @@ def example6-error(): Option[Unit] {
} }
``` ```
### pattern 1: labelled arguments
```
def [t] List.remove_prefix(prefix: List[t], list: 'from List[t])
```
## automatic return types ## automatic return types
``` ```
def add(a: Num, b: Num) -> _ { def add(a: Num, b: Num) -> _ {
@@ -181,7 +186,17 @@ def example(li: List[Char]) -> {t:Token,rem:List[Char]} {
} }
``` ```
## pattern 1: labelled arguments ## recursive data types
``` ```
def [t] List.remove_prefix(prefix: List[t], list: 'from List[t]) type List[t] = {head:t, tail:List[t]}
# now you might notice an issue with this
# `type` defines non-distinct type alisases
# so what is the type of this...
# Introducing: type self references
# the above example is the same as this:
type List[t] = &a {head:t, tail:a}
# example 2:
# a List[List[t]] is just:
&b {head: &a {head:t, tail:a}, tail: b}
``` ```