"Internal error" was a result of ghc not generating any output for this code.
It was updated to instead exit with:
[1 of 1] Compiling SPOJ.TEST ( /tmp/tested.hs, /tmp/tested.o )
Warning: output was redirected with -o, but no output will be generated
because there is no Main module.
I think that now it's informative enough...
I don't know Haskell, but I bet it's "module" that breaks it 
Note that there's a working "TEST" solution in this forum - you might want to compare it with yours.