Compile Haskell code before executing it


Topic is opened following this one hard-apu-haskell

I have the impression (maybe I am wrong) that the haskell code on the server side is executed directly (with runhaskell) and not compiled then executed (ghc myprogram.hs && ./myprogram).
My impression comes from the fact that there is a 10x performance gap between compiled and not compiled.
Ran locally the program that failed (not compiled) took 1.2s, and let’s say that the machines are much slower on the server because of the charge they have to handle. It’s understandable that it could take longer and not pass the test.
But after compiling, the program finishes all 13 tests cases in a row in less than 0.19s (including overhead of Hunit + execution +profiling + without any optimisation option), even with the server being slower, the test should definitely pass :slightly_smiling:

Anyway, I would like like to know whether those are compiled or not.

And if not, then why not doing it ? what’s the point of taking a compiled language if this one is not compiled. :wink:

I really like CG and Haskell, and I want to do both !!
I really look forward to take a full advantage of this language, and beat “brute force” puzzles with haskell instead of being afraid to try them and get stuck whenever I should start relying on my language execution time :confused:

Hoping the best,


I can assure you we use ghc to compile haskell code :wink:

1 Like

I really have a hard time believing that this compiled code fails on the last level (more than one second for the first answer) (this is the old algo).

$ ghc HardApuTest
[1 of 2] Compiling HardApu ( HardApu.hs, HardApu.o )
[2 of 2] Compiling Main ( HardApuTest.hs, HardApuTest.o )
Linking HardApuTest.exe …

$ time ./HardApuTest
Cases: 13 Tried: 13 Errors: 0 Failures: 0

real 0m0.233s
user 0m0.015s
sys 0m0.046s

Assuming that solving all 13 GUI cases takes as long as solving the 13th case for validation (unlikely), that would mean that GC’s machine is 5 times slower (unlikely as well)

Is it ok if I send some files (main.hs + test.hs) to time them on your machine ?

Your algorithm might not fail because of the time, but some other bug.

Most of the time there isn’t only one thing per testcase that can go wrong. Especially the biggest testcase has room for mor subtle bugs to manifest.

Seems unlikely.

My previous algo timeouted on the last check (upon submit), would there have been a bug I would have expected to either see :

  • a crash
  • an invalid response