Hernan Rajchert
Hernan Rajchert

Reputation: 936

How can I specify an exit code with Purescript

If I run the following using pulp run the process ends with status 0.

main :: forall e. Eff (console :: CONSOLE | e) Int
main = do
  log "Hello sailor!"
  pure 137

How can I exit the program with an error without throwing an exception?

Upvotes: 1

Views: 112

Answers (1)

Fyodor Soikin
Fyodor Soikin

Reputation: 80880

If you're running on Node (which is what pulp run does), you should use Node facilities for this. Specifically, the function you want is Node.Process.exit:

import Node.Process(exit)

main = do
    log "Hello sailor!"
    exit 137

Upvotes: 1

Related Questions