Skip to content

Semigroup/Monoid instances for System.Exit.ExitCode

Please add instances for ExitCode along the following lines:

instance Monoid ExitCode where
    mempty = ExitSuccess
    mappend ExitSuccess b = b
    mappend a           _ = a

This allows the summary result of multiple child processes to be computed naturally. For example:

mconcat <$> mapM system commands

The result is ExitSuccess if they all succeeded, and the leftmost failure otherwise. This is similar to the behaviour of set -e in bash.

Edited by Neil Mayhew
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information