HigherOrderCO / Kind

A modern proof language
https://higherorderco.com
MIT License
3.58k stars 142 forks source link

Support recursive types on type system #505

Closed aripiprazole closed 4 months ago

VictorTaelin commented 1 year ago

Kind already supports recursive types. For example:

SNat : Type
SNat = (t: Type) -> (s: SNat -> t) -> (z: t) -> t

Works and type-checks. But actually trying to use it will be problematic. For example:

SNat.zero : SNat
SNat.zero = t => s => z => z

Checks, but:

SNat.succ (n: SNat) : SNat
SNat.succ n = t => s => z => (s n)

Doesn't; it will hang. That's because the equal function will be stuck in a loop (print it to get an idea). Ideally, Kind would deal with that seamlessly, but that's not the case yet. One way this could be done, as suggested by @tjjfvi and @FranchuFranchu: