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

Support MLton-style aggressive type inference #18

Open
shwestrick opened this issue Jan 13, 2023 · 1 comment
Open

Support MLton-style aggressive type inference #18

shwestrick opened this issue Jan 13, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@shwestrick
Copy link

Problem

Millet reports a 5023 error for the definition of f here:

type foo = {x: int, y: string}

fun f foo = #x foo

fun g (foo: foo) = f foo

However, this code is accepted by MLton. The reason MLton accepts it is because the type of f can be fully inferred within the definition of g. (You can confirm this deleting the definition of g; MLton will then reject it.)

Solution

It would be nice for Millet to optionally support more aggressive type inference, to mimic MLton.

Perhaps this could even be enabled by default when workspace.root is a .mlb.

@azdavis
Copy link
Owner

azdavis commented Jan 14, 2023

Put this test in as a failing test in 8973f80.

Supporting this would be somewhat non trivial. I'd have to think about what sort of invariants we currently rely on by generalizing per declaration, that would be broken if we started doing it across declarations. It'd also probably just be a bit of work to restructure the way we generalize to be able to do this.

Here's where we do generalization for val decs; this is also thus currently the only place we emit the unresolved record ty error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants