[GHC] #14349: Semigroup/Monoid instances for System.Exit.ExitCode

GHC ghc-devs at haskell.org
Fri Oct 13 14:02:38 UTC 2017


#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@… (removed)


Old description:

> Please add instances for ExitCode along the following lines:
>
> {{{#!hs
> 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:
>
> {{{#!hs
> mconcat <$> mapM system commands
> }}}
>
> The result is `ExitSuccess` if they all succeeded, and the leftmost
> failure otherwise

New description:

 Please add instances for ExitCode along the following lines:

 {{{#!hs
 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:

 {{{#!hs
 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`.

--

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14349#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list