ethanuppal / pulsar

Programming language for building hardware accelerators.
Other
1 stars 0 forks source link

Improve type inference #3

Open ethanuppal opened 1 month ago

ethanuppal commented 1 month ago

The current type inference and constraint setup is very limiting. In particular:

  1. It doesn't carry through much lexical information, leading to less-than-ideal error messages (see #2).
  2. It only allows constraints for type equality.

In fixing 2, there would be type classes and type/numeric parameters. The current setup with arrays and array literals involves a magic ARRAY_TYPE_UNKNOWN_SIZE constant. It would be better if an array was declared as a parametric type over its size. In order to handle type classes, the constraint system would need to extend to be able to prove derivation of a type or type class from another type class in addition to equality between types. (Side note: type classes as first class???)

ethanuppal commented 1 month ago

I aim to prove the following kinds of theorems (forgive the heterogenous notation):

I will likely have to do research into the algorithms that implement the latter kinds of proofs. It is also necessary to determine how to encode lexical context into these theorems for useful error messages. To start, I will read more of Static Program Analysis.