By default, a source code without extension would get overwritten by executable on *nix
If I have a source code without an extension, say
foo, and I forget to specify the output file via
-o, GHC will overwrite it with the executable itself after compilation. This occurs only on *nix-like operating systems. Presumably something similar could happen on Windows – fortunately, those who use
.exe for source code are probably among the minority.
#!/bin/sh echo >foo 'main=undefined' ghc -x hs foo less foo # 'foo' now contains binary data