
#14349: Semigroup/Monoid instances for System.Exit.ExitCode -------------------------------------+------------------------------------- Reporter: neil.mayhew | Owner: (none) Type: feature request | Status: upstream Priority: low | Milestone: Component: libraries/base | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by neil.mayhew): * cc: hvr, ekmett, core-libraries-committee (added) Comment: As far as I can see, the only other reasonable `Monoid` instance would be to have success if any succeeded, but this is almost never what you want. It would be possible to use a similar approach to the `Any`/`All` newtypes for `Bool`, but this seems like overthinking it. It would be possible to favour the rightmost failure, but I don't see much point in this. That's why I mentioned `set -e`, which returns the exit code of the first, ie leftmost, failure. The fact that bash short-circuits the rest of the evaluation is mostly an issue of lazy evaluation. The semantics of the summary exit code are the same, although of course the side effects are different. Adding a named function would be a valid approach, but it's a pity to add a single-use function when we already have a nice general way to view the problem with `Monoid`. If `mempty` is an issue then it could be a `Semigroup` instance. However, it seems natural to me that running no child processes is considered successful. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14349#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler