A type system for haku #110

Open
opened 2024-10-28 21:40:01 +01:00 by liquidex · 0 comments
Owner

A type system would allow us to have more clear error messages, as well as make the language easier to analyse for IDE-style features.

This type system would not be visible to outside users, but rather use full program type inference to point out mistakes ahead of time without you having to annotate anything.

-- addVectors : \vec, vec -> vec
addVectors = \a, b ->
  -- vecX : \vec -> number
  --   => therefore a must be a vec
  --   => therefore b must be a vec
  vec (vecX a + vecX b) (vecY a + vecY b)

I've never written a type system with constraint-based type inference like this before, so it will probably require a lot of research work to be pulled off. I also worry the error messages may end up not being clear enough for users to understand, but we'll see how that goes.

A type system would allow us to have more clear error messages, as well as make the language easier to analyse for IDE-style features. This type system would not be visible to outside users, but rather use full program type inference to point out mistakes ahead of time without you having to annotate anything. ``` -- addVectors : \vec, vec -> vec addVectors = \a, b -> -- vecX : \vec -> number -- => therefore a must be a vec -- => therefore b must be a vec vec (vecX a + vecX b) (vecY a + vecY b) ``` I've never written a type system with constraint-based type inference like this before, so it will probably require a lot of research work to be pulled off. I also worry the error messages may end up not being clear enough for users to understand, but we'll see how that goes.
liquidex added the
c:haku
label 2024-10-28 21:40:01 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: liquidex/rkgk#110
No description provided.