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

Consider purs codegen command #3339

Open
garyb opened this issue Apr 28, 2018 · 7 comments · May be fixed by #4092
Open

Consider purs codegen command #3339

garyb opened this issue Apr 28, 2018 · 7 comments · May be fixed by #4092

Comments

@garyb
Copy link
Member

garyb commented Apr 28, 2018

This was mentioned somewhere in the discussion about how to deal with --dump-corefn, etc. but the general ideal was the compiler could pick up the corefn and then perform JS codegen on it, so you could have something like:

purs compile --codegen corefn src/**/*.purs
-- custom corefn optimizer tool
purs codegen ...
@garyb garyb added this to the Ideas milestone Apr 28, 2018
@themattchan
Copy link

What if you had

purs compile --optimizer ./myoptimizer src/**/*.purs

where myoptimizer is a program, conceptually of type corefnJSON -> corefnJSON, that reads the original corefn from stdin and dumps the rewritten IR to stdout?

@coot
Copy link
Contributor

coot commented May 1, 2018

Some optimizations might be non local, requiring a signature [CoreFn.Module] -> [CoreFn.Module]. Using json, will open the additional possibility of writing plugins in purescript :).

@colinwahl
Copy link
Contributor

Is this still something that people would be open to adding?

If so, I can write up a plan and start work on it.

@JordanMartinez
Copy link
Contributor

You got two hearts, so it seems like it.

@colinwahl
Copy link
Contributor

My initial plan is to implement purs codegen path/to/**/corefn.json path/to/**/more/corefn.json - which will resolve globs to get a list of files, decode the CoreFn.Module within each, and then run codegen on those modules. The outputted js files would go under output, namespaced under the appropriate module name.

I thought about not including the file globs argument, instead just assuming they will be in output/**/corefn.json, but I'd like to leave open the possibility of tools placing the corefn.json files wherever they see fit.

@colinwahl colinwahl linked a pull request May 19, 2021 that will close this issue
5 tasks
@MaybeJustJames
Copy link

MaybeJustJames commented Jan 5, 2022

@colinwahl would having zephyr DCE in the compiler change the need for this?

Edit: My mistake. This would actually be a pre-requisite

@garyb
Copy link
Member Author

garyb commented Jan 5, 2022

I would say "not necessarily" 😉.

We'd still need to produce un-zephyr'd artifacts to have the standard purs compile work correctly for incremental compilation, so you'd only use it for a production build/pre-bundle step, and it would write them to a separate location than the standard output.

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

Successfully merging a pull request may close this issue.

6 participants