Re:Types as axioms, or: playing god with static types
by valenterry on Saturday August 15, 2020 @11:33PM
(#24174780)
I think I'm just confused by the examples chosen. E.g.:
> type NonEmptyArray<T> = [T, ...T[]];
I'm not very familiar with Typescript, but isn't that also a "constructive" approach, rather than a "constraining" one? It reads to me like "NonEmptyArray is an array that has one element and then more elements that come from pulling elements from another array".
Typescript uses a language construct here for a special usecase, but the point still stands.
> type NonEmptyArray<T> = [T, ...T[]];
I'm not very familiar with Typescript, but isn't that also a "constructive" approach, rather than a "constraining" one? It reads to me like "NonEmptyArray is an array that has one element and then more elements that come from pulling elements from another array".
Typescript uses a language construct here for a special usecase, but the point still stands.