summaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Main.hs b/Main.hs
index ee98ef7..6ad49d8 100644
--- a/Main.hs
+++ b/Main.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
module Main (main) where
import Control.Applicative
@@ -6,6 +8,7 @@ import Data.Maybe
import Data.List
import Data.Monoid
( Monoid(..) )
+import qualified Data.Semigroup as S
-- cabal
import Distribution.Simple.Setup
@@ -36,6 +39,8 @@ import Portage.PackageId ( normalizeCabalPackageId )
import System.Environment ( getArgs, getProgName )
import System.Directory ( doesDirectoryExist )
import System.Exit ( exitFailure )
+{-# LANGUAGE CPP #-}
+
import System.FilePath ( (</>) )
import qualified HackPort.GlobalFlags as H
@@ -56,14 +61,24 @@ data ListFlags = ListFlags {
listVerbosity :: Flag Verbosity
}
+#if MIN_VERSION_base(4,9,0)
+instance S.Semigroup ListFlags where
+ a <> b = ListFlags {
+ listVerbosity = combine listVerbosity
+ }
+ where combine field = field a S.<> field b
+#endif
+
instance Monoid ListFlags where
mempty = ListFlags {
listVerbosity = mempty
}
+#if !(MIN_VERSION_base(4,11,0))
mappend a b = ListFlags {
listVerbosity = combine listVerbosity
}
where combine field = field a `mappend` field b
+#endif
defaultListFlags :: ListFlags
defaultListFlags = ListFlags {
@@ -119,16 +134,27 @@ data MakeEbuildFlags = MakeEbuildFlags {
, makeEbuildCabalFlags :: Flag (Maybe String)
}
+#if MIN_VERSION_base(4,9,0)
+instance S.Semigroup MakeEbuildFlags where
+ a <> b = MakeEbuildFlags {
+ makeEbuildVerbosity = combine makeEbuildVerbosity
+ , makeEbuildCabalFlags = makeEbuildCabalFlags b
+ }
+ where combine field = field a S.<> field b
+#endif
+
instance Monoid MakeEbuildFlags where
mempty = MakeEbuildFlags {
makeEbuildVerbosity = mempty
, makeEbuildCabalFlags = mempty
}
+#if MIN_VERSION_base(4,9,0)
mappend a b = MakeEbuildFlags {
makeEbuildVerbosity = combine makeEbuildVerbosity
, makeEbuildCabalFlags = makeEbuildCabalFlags b
}
where combine field = field a `mappend` field b
+#endif
defaultMakeEbuildFlags :: MakeEbuildFlags
defaultMakeEbuildFlags = MakeEbuildFlags {
@@ -180,14 +206,24 @@ data UpdateFlags = UpdateFlags {
updateVerbosity :: Flag Verbosity
}
+#if MIN_VERSION_base(4,9,0)
+instance S.Semigroup UpdateFlags where
+ a <> b = UpdateFlags {
+ updateVerbosity = combine updateVerbosity
+ }
+ where combine field = field a S.<> field b
+#endif
+
instance Monoid UpdateFlags where
mempty = UpdateFlags {
updateVerbosity = mempty
}
+#if !(MIN_VERSION_base(4,11,0))
mappend a b = UpdateFlags {
updateVerbosity = combine updateVerbosity
}
where combine field = field a `mappend` field b
+#endif
defaultUpdateFlags :: UpdateFlags
defaultUpdateFlags = UpdateFlags {
@@ -284,16 +320,27 @@ data MergeFlags = MergeFlags {
, mergeCabalFlags :: Flag (Maybe String)
}
+#if MIN_VERSION_base(4,9,0)
+instance S.Semigroup MergeFlags where
+ a <> b = MergeFlags {
+ mergeVerbosity = combine mergeVerbosity
+ , mergeCabalFlags = mergeCabalFlags b
+ }
+ where combine field = field a S.<> field b
+#endif
+
instance Monoid MergeFlags where
mempty = MergeFlags {
mergeVerbosity = mempty
, mergeCabalFlags = mempty
}
+#if !(MIN_VERSION_base(4,11,0))
mappend a b = MergeFlags {
mergeVerbosity = combine mergeVerbosity
, mergeCabalFlags = mergeCabalFlags b
}
where combine field = field a `mappend` field b
+#endif
defaultMergeFlags :: MergeFlags
defaultMergeFlags = MergeFlags {