Not sure whether these are supposed to exit with status 0 or if it doesn’t matter, so here’s one of each.
haskell_loop.hs is an infinite loop (well, in GHC, it throws a NonTermination exception instead).
haskell_term.hs is AFAICT the smallest program that terminates successfully; it even has output! (But only because print 0 is slightly shorter than return().)
Actually, the smallest syntactically valid file is empty. But in an actual program the Main module (which a file with no module header is) has to at least contain the main function. And similarly, main=0 would be shorter but main is expected to have the type IO ().
Not sure whether these are supposed to exit with status
0
or if it doesn’t matter, so here’s one of each.haskell_loop.hs
is an infinite loop (well, in GHC, it throws a NonTermination exception instead).haskell_term.hs
is AFAICT the smallest program that terminates successfully; it even has output! (But only becauseprint 0
is slightly shorter thanreturn()
.)Actually, the smallest syntactically valid file is empty. But in an actual program the
Main
module (which a file with no module header is) has to at least contain themain
function. And similarly,main=0
would be shorter but main is expected to have the typeIO ()
.