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

Add tokenizing minifier. #14

Merged
merged 1 commit into from
Feb 9, 2023
Merged

Conversation

kindaro
Copy link
Contributor

@kindaro kindaro commented Feb 9, 2023

Ideally we should prefer a minifier that calls for GHC to parse the file and then define a custom printer for GHC's internal representation. But for now this.

Ideally we should prefer a minifier that calls for GHC to parse the file
and then define a custom printer for GHC's internal representation. But
for now this.
@kindaro
Copy link
Contributor Author

kindaro commented Feb 9, 2023

Heya folks! This is a poorly written program, but it works. You need to add curled braces and semicolons over all your program, so that it becomes white space insensitive. Then the minifier will turn it into a brick of inscrutable code no more than 80 characters wide.

Talk to me about possible improvements!

@simonmichael simonmichael merged commit 6a1648f into haskell-game:main Feb 9, 2023
@simonmichael
Copy link
Contributor

Interesting! Thanks!

@simonmichael
Copy link
Contributor

I don't have details, but FWIW it did not produce compiling code for me the two times I tried it. Would be good to have more test reports.

@kindaro
Copy link
Contributor Author

kindaro commented Feb 12, 2023

@simonmichael There are two ways my minifier can break.

  • You have not made your code white space invariant. You need to put curly braces and semicolons by hand.
  • You have white space inside strings. Minifier then sees them as separate tokens and it will sometimes insert a line break.

Yes, this is not a smart minifier… I put it together as fast as I can, to have some estimate of how much I can fit into a 10 lines game. I shall hopefully do a better minifier later. I want to use GHC lexer but it is not exactly easy.

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