This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
Extensible Tables #47
tiansivive
started this conversation in
Ideas
Replies: 1 comment
-
Interestingly, type Foo = { [0,0]: String, [0,1]: Int } Would mean a term can only ever have type Foo = { [Int, Int]: String, [0,1]: Int } would mean any indexes of the form Perhaps a better way of defining such types is allowing: type Foo = { [0,1]: Int | [Int, Int]: String } Here we get rid of the rigid type variable type Foo = \r => { [0,1]: Int | ([Int, Int]: String | r)} which we could allow as: type Foo = \r => { [0,1]: Int | [Int, Int]: String | r} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Combine Lua's concept of tables with row polymorphism.
Tables allows for any type to be used as the indexing key. We can generalise this idea by extending the simple key-val pair to any n sized tuple. Any element of such a tuple can act as an index.
This is mimic Prolog's facts/relations
We can leverage row polymorphism for extensibility. Rather than having a
Row Type
kind, we can instead have aRow Relation
, whereRelation
is of kindType -> Type -> Type
.This would allow multi-key records, hashmaps, lists and arrays to all be specializations of a
Extensible Table
.String indexed record:
Array:
Multi-key, 2d Matrix
Question:
Relation Unit Type
? Is that just aTuple
?Relation Nat Unit
? Is that an error? Or do we default to integer index, as in, a sequential array?Syntactic sugar
Based off Typescript:
String indexed table:
desugar to
Note
The following would not work:
Because the desugared type var
r
is rigid, and cannot be unified by any specific term.This might cause confusion, so perhaps we need another syntax or some mechanism to allow such "generic" types.
For example, would it be possible to allow:
???
Beta Was this translation helpful? Give feedback.
All reactions