Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exit quietly (without exception) haskell

I know that

exitWith ExitSuccess

exits the program, but it outputs

*** Exception: ExitSuccess

I am wanting to know if there is way to exit without outputting anything onto the screen?

like image 471
Ali Avatar asked Apr 20 '15 19:04

Ali


1 Answers

Expanding the above comments here (Credits to Reid, Bakuriu and Jeffrey). It's highly likely that you are executing the following program in ghci:

import System.Exit

main :: IO ()
main = exitWith ExitSuccess

Now in terminal:

$ ghci
λ> :load crash.hs -- crash.hs is the filename
λ> main
*** Exception: ExitSuccess

Note that ghci and ghc are different. ghci is used as a REPL for Haskell. The above code when compiled and executed like the following won't produce any message:

$ ghc -o crash crash.hs 
$ ./crash

Note that the REPL is invoked through the program named ghci. For compiling and producing an executable, you have to use a executable named ghc.

like image 185
Sibi Avatar answered Oct 25 '22 23:10

Sibi