Software Tools in Haskell: noop

exit successfully

Posted on 2016-02-08 by nbloomf
Tags: software-tools-in-haskell, literate-haskell

This page is part of a series on Software Tools in Haskell.

This post is literate Haskell; you can load the source into GHCi and play along.

As usual, we start with some imports.

-- sth-noop: exit successfully
module Main where

import System.Exit (exitSuccess)

One of the most important things a program can do is exit successfully when it is finished. This is what (all, really) that noop does.

main :: IO ()
main = do
  -- real tools do stuff here

This program doesn’t compute anything, so in that sense it’s not much of a tool. But it does illustrate the basic structure of a Haskell program. The main function is what gets executed when a program is run; everything else (parsing command line arguments, reading files, whatever) is done within main. We signal that the program has exited successfully with the aptly-named exitSuccess function.