A code golf challenge decribed in this post by Taylor Fausak drowned some people into madness.
Manually judging answers for the challenge was so tiresome and error-prone. This program automates it.
- GHC 8.10.* is installed and can invoke its compiler by command
ghc
. - cabal-install is set up.
cabal build judge
- Prepare
- Haskell program to be tested (
a.hs
) - A file listing name of GHC language extensions (
extensions.txt
) each separated by whitespace characters
- Haskell program to be tested (
cabal run -- judge a.hs --exts extensions.txt
$ cabal run -- judge original.hs --exts extensions.txt
Up to date
PASSED
Score(chars/exts):3.5238095238095237
=================================
SourceStat {srcLenCodepoints = 74, srcLenUtf8Bytes = 84}
exts=21=21+0
-
PASSED
-- Input is valid. The program compiles with given list of extensions, and removing any one of extension make it fail to compile. If the input was invalid,FAILED
is printed out. -
Score(chars/exts):
-- How good the input is. Measured by how many characters (in Unicode codepoints) are in the program, divided by how many extensions required. -
SourceStat{..}
-- Exists for the time when you want to measure by bytes -
exts=N=E+I
-- Some extensions imply other extensions.If an extension
E
implies another extensionI
, enablingE
also enablesI
. This can be overridden by specifyingNoI
. It was not clear how to score:- One requires
E
but don't requireI
to be enabled - One requires both
E
andI
to be enabled
This judge program don't allow former to advertize "require 2 extensions", but allow for latter. When seeing both
E
andI
in the extensions list file, the judge counts them as 2 extensions, and rejects the former program.The output
exts=N=E+I
means the judge recognizesN
extensions total, includingI
extensions implied by other extensions listed andE
extensions no other extensions imply it. - One requires
original.hs
,extensions.txt
: One presented in the blog postisovector.hs
,extensions_isovector.txt
: Current best, From comments on reddit
This program does not test the case 2 or more extensions are omitted simultaneously.