summaryrefslogtreecommitdiff
path: root/utils/runghc
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2017-08-31 09:49:20 +0200
committerHerbert Valerio Riedel <hvr@gnu.org>2017-08-31 09:49:20 +0200
commitb2c2e3e818b8aa69af711cefa7efeadedc3f2e4e (patch)
treec58b69f6c8e14a7604be28d30473c1a4bdfbd5e8 /utils/runghc
parentc0feee90118333dac817cfad6f2dedc0a886d1bd (diff)
downloadhaskell-b2c2e3e818b8aa69af711cefa7efeadedc3f2e4e.tar.gz
Add missing Semigroup instances in utils/{hpc,runghc}
This is a follow-up to c0feee90118333dac817cfad6f2dedc0a886d1bd
Diffstat (limited to 'utils/runghc')
-rw-r--r--utils/runghc/Main.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/utils/runghc/Main.hs b/utils/runghc/Main.hs
index b5d4a4a9ca..dec53eefb0 100644
--- a/utils/runghc/Main.hs
+++ b/utils/runghc/Main.hs
@@ -19,6 +19,7 @@
module Main (main) where
import Control.Exception
+import Data.Semigroup as Semi
import System.Directory
import System.Environment
import System.Exit
@@ -77,14 +78,17 @@ data RunGhcFlags = RunGhcFlags (Maybe FilePath) -- GHC location
| Help -- Print help text
| ShowVersion -- Print version info
+instance Semi.Semigroup RunGhcFlags where
+ Help <> _ = Help
+ _ <> Help = Help
+ ShowVersion <> _ = ShowVersion
+ _ <> ShowVersion = ShowVersion
+ RunGhcFlags _ <> right@(RunGhcFlags (Just _)) = right
+ left@(RunGhcFlags _) <> RunGhcFlags Nothing = left
+
instance Monoid RunGhcFlags where
mempty = RunGhcFlags Nothing
- Help `mappend` _ = Help
- _ `mappend` Help = Help
- ShowVersion `mappend` _ = ShowVersion
- _ `mappend` ShowVersion = ShowVersion
- RunGhcFlags _ `mappend` right@(RunGhcFlags (Just _)) = right
- left@(RunGhcFlags _) `mappend` RunGhcFlags Nothing = left
+ mappend = (<>)
parseRunGhcFlags :: [String] -> (RunGhcFlags, [String])
parseRunGhcFlags = f mempty