We want a more user-friendly type system. Numpy has interesting infrastructure for creating numpy dtypes, but it leaves a lot to be desired too. Here’s what I’m thinking:
- We leave the T-Type system alone, but build helpful architecture on top of it so people never need to write
TInt32()
. Scalar types should behl.int32
,hl.str
, etc. However, this presents a problem: clash between existing expr functions (hl.str is the toString expr method) and the types. One possibility is that the types have a defined__call__
method that’s an expr conversion, but this may be confusing. This also doesn’t solve the problem of how array and struct types work. Shouldhl.array
construct a type or value? How abouthl.struct
? - We write a type parser in Python/Cython that handles similar-looking type strings to what we have in Scala. Cotton likes the following syntax:
struct{x:array<int32>, y: str, z: struct{z2: dict<str, int32>}}
- We use this type parser optionally in most places that require type inputs (
hl.import_table
,hl.null
, etc).