This commit is contained in:
2025-09-12 10:37:44 +02:00
parent 52fe4da3b7
commit f6b553eb5a

View File

@@ -188,15 +188,15 @@ def example(li: List[Char]) -> {t:Token,rem:List[Char]} {
## recursive data types ## recursive data types
``` ```
type List[t] = {head:t, tail:List[t]} type List[t] = 'End | 'Cons {head:t, tail:List[t]}
# now you might notice an issue with this # now you might notice an issue with this
# `type` defines non-distinct type alisases # `type` defines non-distinct type alisases
# so what is the type of this... # so what is the type of this...
# Introducing: type self references # Introducing: type self references
# the above example is the same as this: # the above example is the same as this:
type List[t] = &a {head:t, tail:a} type List[t] = &a ('End | 'Cons {head:t, tail:a})
# example 2: # example 2:
# a List[List[t]] is just: # a List[List[t]] is just:
&b {head: &a {head:t, tail:a}, tail: b} &b ('End | 'Cons {head: &a ('End | 'Cons {head:t, tail:a}), tail: b})
``` ```