-
Notifications
You must be signed in to change notification settings - Fork 31
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
Question about minifying and unminifying. #52
Comments
I wrote my first submission in minified form by hand. This was only practical because I had a very clear idea of what I wanted to create from the outset, but even then it took me a whole day to write it! But even if you write it in readable form and use a minification tool, you'll still have to do a lot of manual work to make it as small as possible. The techniques that I used include:
{- Some definitions ... -} ;k=take i
['a'..]; {- Some more definitions ... -}
|
I contributed a minifier. Try it out! |
Here's my current approach:
|
Oh, that's one nice trick... :) That means I might have a chance to jam a minimax strategy in? |
|
I just learnt another little space-saving trick while trying to maxify matchmaking. It turns out that arguments beginning with a digit end at the last digit. So e.g.
More specifically, if its name is
the number of function usages that you need before you start saving space is:
|
Thank you for sharing. I was curious to find out how to automate the process of minifying scripts. I assumed that there would be readily available solutions for this, similar to those offered for JavaScript, but it appears that this may not be the case for Haskell. This could be due to a lower demand for such solutions in the Haskell community compared to front-end development. Regardless, I appreciate your contributions. If there are no further comments, I will consider this discussion closed. |
Bear in mind that it's impossible to write an optimal minifying script though (if it was, then Kolmogorov complexity would be computable). So even when using one that seems very effective, there's a good chance that there will be things that you could do to make the code even smaller. |
@hyunsooda please give minify.hs a try and let us know your experience. |
I use a similar approach as @simonmichael :
In tsp I used this technique to minify I run |
The top-level minify.hs didn't work for me, so I wrote my own in #63 |
I tried both versions and neither worked. The tested code is: import System.Info
main = do
print os
print arch
print compilerName
print compilerVersion The output of both scripts is the same as follows: import System.Info main=do print os print arch print compilerName print
compilerVersion So, I should manually fix it like below (i.e., adding curly braces and semicolons appropriately): {import System.Info; main=do{print os; print arch; print compilerName;
print compilerVersion}} |
Yes both scripts need semicolons and braces in their input. It's written in a comment in my minifier and in the global README. You can keep the indentation though; the following code should be minified correctly: import System.Info;
main = do {
print os;
print arch;
print compilerName;
print compilerVersion
} |
I confirm that /minify.hs and /hackage/brickbreaker.hs both handle fgaz's example above, and produce the same 90-byte output. |
https://github.com/haskell-game/tiny-games-hs/tree/main/hackage/7up7down has a cool trick: paste minified code into ormolu's online demo to unminify. |
Really cool. I was using Ormole for formatting, but I never hacked it to unminify. Work nicely. |
For what it's worth, I tinkered with |
Some of the submitted games have been compressed to adhere to the guidelines. Can anyone share their techniques for effectively compressing (minifying) the code, as well as the steps for decompressing (unminifying) them?
The text was updated successfully, but these errors were encountered: