Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement kind inference #46

Open
osa1 opened this issue Jan 8, 2025 · 0 comments
Open

Implement kind inference #46

osa1 opened this issue Jan 8, 2025 · 0 comments

Comments

@osa1
Copy link
Member

osa1 commented Jan 8, 2025

Currently we infer kinds of type variables by just looking at where they are used in the signature.

If a type variable is used in row position, we infer the kind as "row".

Otherwise we infer it as "star".

For type declarations, we infer all kinds as "star".

This is not right, example:

# `r` is currently `*`, but it should be `row`.
type Test[r]:
    variant: [A, B, ..r]

# `r` is currently `*`, but it should be `row`.
f1[r](t: Test[r])
    match t.variant:
        ~A: printStr("A")
        ~B: printStr("B")
        other: printStr("Other")

The reason why this doesn't cause issues right now is because we also allow non-kind-preserving unification, e.g. we can link a variable of kind * to a row type.

Haskell 98 kind inference should work.

I started working on this in kind_inference branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant