Feature: Hindley Milner polymorphic type inference (cl-typeck) #16

Open
opened 2024-07-31 08:42:57 +00:00 by j · 0 comments
Owner

Feature Progress

  • Decide on typing rules for each kind of expression
  • Implement a variant of a HM algorithm that operates on the typed AST

Feature description

This feature will allow users to omit type annotations wherever the inference algorithm can determine the type.

Problems

  • Generalized type inference is undecidable. Conlang is pretty limited, so it may be doable.
  • Where is it legal to omit type information? How would that be decided?
  • Are untagged polymorphic functions desirable?

Example

fn hex(n: u64) -> String {
    // ...
}

fn main() {
    let x = hex(1000); // x: String
    let y = 10 + 3;    // y: {int}
    print(hex(y), x);  // y: u64
# Feature Progress <!-- Describe the steps for implementing this feature --> - [ ] Decide on typing rules for each kind of expression - [ ] Implement a variant of a HM algorithm that operates on the typed AST # Feature description <!-- [Feature name] does a cool thing that you should describe here --> This feature will allow users to omit type annotations wherever the inference algorithm can determine the type. # Problems - Generalized type inference is undecidable. Conlang is pretty limited, so it may be doable. - Where is it legal to omit type information? How would that be decided? - Are untagged polymorphic functions desirable? # Example <!-- Demonstrate this feature with a clear, concise code example Right now, we're (ab)using Rust syntax highlighting, since it most closely matches what I'm currently aiming for --> ```rust fn hex(n: u64) -> String { // ... } fn main() { let x = hex(1000); // x: String let y = 10 + 3; // y: {int} print(hex(y), x); // y: u64 ```
j added the
enhancement
label 2024-07-31 08:42:57 +00:00
j added this to the Static Analysis project 2024-07-31 08:59:53 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
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: j/Conlang#16
No description provided.