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

Specialize types pass #7149

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Specialize types pass #7149

wants to merge 15 commits into from

Conversation

rtfeldman
Copy link
Contributor

@rtfeldman rtfeldman commented Oct 8, 2024

This isn't trying to do anything with expressions yet; all it does is that you give it a Variable and Subs and it monomorphizes that variable.

This is based on the cor implementation at https://github.com/ayazhafiz/cor/blob/b67174d98b6dde16809b3606f9f88d4863d8743f/experiments/lss/monotype/lower_type.ml#L62-L63

Copy link
Member

@ayazhafiz ayazhafiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good generally. Is the purpose of monomorphize that you will eventually do all the cloning of expressions/specialization to exact types there?

In monomorphize_type, I would be sure to clone the type variable. You don't want to reuse the same one, especially if the variable is generic.

I would consider removing most of the tests for now, or using the uitest framework instead. I'm not sure specializing \x, y -> x y to ([] -> []), [] -> [] says very much. really, you'll want to see that the specialization produces specific instantiations.

@rtfeldman
Copy link
Contributor Author

rtfeldman commented Oct 8, 2024

Yeah I plan to add specialize_expr which does the expr cloning part next, at which point I'll throw out these tests. I mainly just wanted to give myself a sense of this part working in isolation before getting exprs involved.

Great point about cloning the variable! I think the way we want to do that is to make a new var here: https://github.com/roc-lang/roc/pull/7149/files#diff-17f90baf2650b85b580fc6e1b09ed4277812b36c92697d17f2473dba5a5c615cR77

...and then change the next line to cache.set_monomorphic(new_var); return new_var; yeah?

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

Successfully merging this pull request may close these issues.

2 participants