Are there dynamic languages with fully fleshed ADT out there? Mostly curious if Option<Option<T>> is representable. It's not in typescript?
Conversation
`Option<T>` is a tagged union. Would be the equivalent `type Option<T> = { tag = 'some', value: T } | { tag: 'none' }` in Typescript.
1
How how do you express Option<Option<T>> then?
1
as far as I can see it's basically a flat union in TS?
2
Replying to
are you sure? I only find "discriminated unions" in typescript and they do not do this
1
They do. You can put any type into the tagged "some" value, including another tagged union. (same for other langs with tagged unions)
1
Show replies
Yep. `type Option<T> = T | nil` doesn't work, because you don't have a tag.
1
Show replies


