rems-project / sail

Sail architecture definition language
Other
563 stars 92 forks source link

Undocumented concepts: "type", "enum", "struct", "union" #606

Open ThinkOpenly opened 4 days ago

ThinkOpenly commented 4 days ago
Alasdair commented 4 days ago

Is Int (capital I) a built-in type? If not, that could be confusing.

In a sense. To be precise it's a built in kind, which is the type of a type, so we might say:

For something like bitvector, that is a type constructor with kind Int -> Type, means that bitvector creates a type by taking a type-level integer as an argument.

Most mainstream languages just have a single kind for all types, so don't expose this in the syntax, and very few languages have any higher-kinded polymorphism like Haskell (Sail does not have this either though) that would require distinguishing Type and Type -> Type in the syntax. Sail has this because we distinguish between integers, constraints, and 'regular types' in types (using the kinds Int, Bool, and Type).

In theory we could make this more transparent with some better kind-inference, as it should be possible to always infer kinds. Not sure how best to present this in the manual without going to deep into type theory.