summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Main.hs47
-rw-r--r--Merge/Dependencies.hs18
-rw-r--r--Portage/Dependency/Print.hs37
-rw-r--r--Portage/PackageId.hs6
-rw-r--r--Portage/Use.hs6
-rw-r--r--Portage/Version.hs6
-rw-r--r--hackport.cabal2
7 files changed, 104 insertions, 18 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 {
diff --git a/Merge/Dependencies.hs b/Merge/Dependencies.hs
index 807b3c9..d49ed98 100644
--- a/Merge/Dependencies.hs
+++ b/Merge/Dependencies.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
{- | Merge a package from hackage to an ebuild.
-}
module Merge.Dependencies
@@ -32,6 +34,10 @@ import qualified Portage.GHCCore as GHCCore
import Debug.Trace ( trace )
+#if MIN_VERSION_base(4,9,0)
+import Data.Semigroup (Semigroup(..))
+#endif
+
-- | Dependencies of an ebuild
data EDep = EDep
{
@@ -42,6 +48,16 @@ data EDep = EDep
}
deriving (Show, Eq, Ord)
+#if MIN_VERSION_base(4,9,0)
+instance Semigroup EDep where
+ (EDep rdepA rdep_eA depA dep_eA) <> (EDep rdepB rdep_eB depB dep_eB) = EDep
+ { rdep = Portage.DependAllOf [rdepA, rdepB]
+ , rdep_e = rdep_eA `S.union` rdep_eB
+ , dep = Portage.DependAllOf [depA, depB]
+ , dep_e = dep_eA `S.union` dep_eB
+ }
+#endif
+
instance Monoid EDep where
mempty = EDep
{
@@ -50,12 +66,14 @@ instance Monoid EDep where
dep = Portage.empty_dependency,
dep_e = S.empty
}
+#if !(MIN_VERSION_base(4,11,0))
(EDep rdepA rdep_eA depA dep_eA) `mappend` (EDep rdepB rdep_eB depB dep_eB) = EDep
{ rdep = Portage.DependAllOf [rdepA, rdepB]
, rdep_e = rdep_eA `S.union` rdep_eB
, dep = Portage.DependAllOf [depA, depB]
, dep_e = dep_eA `S.union` dep_eB
}
+#endif
resolveDependencies :: Portage.Overlay -> Cabal.PackageDescription -> Cabal.CompilerInfo
-> [Cabal.PackageName] -> Cabal.PackageName
diff --git a/Portage/Dependency/Print.hs b/Portage/Dependency/Print.hs
index 9c9ed02..2c941aa 100644
--- a/Portage/Dependency/Print.hs
+++ b/Portage/Dependency/Print.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
module Portage.Dependency.Print
(
dep2str
@@ -11,7 +13,8 @@ import Portage.PackageId
import qualified Distribution.Text as DT
import qualified Text.PrettyPrint as Disp
-import Text.PrettyPrint ( (<>), vcat, nest, render )
+import Text.PrettyPrint ( vcat, nest, render )
+import Text.PrettyPrint as PP ((<>))
import Portage.Dependency.Types
@@ -21,17 +24,17 @@ dispSlot AnyBuildTimeSlot = Disp.text ":="
dispSlot (GivenSlot slot) = Disp.text (':' : slot)
dispLBound :: PackageName -> LBound -> Disp.Doc
-dispLBound pn (StrictLB v) = Disp.char '>' <> DT.disp pn <-> DT.disp v
-dispLBound pn (NonstrictLB v) = Disp.text ">=" <> DT.disp pn <-> DT.disp v
+dispLBound pn (StrictLB v) = Disp.char '>' PP.<> DT.disp pn <-> DT.disp v
+dispLBound pn (NonstrictLB v) = Disp.text ">=" PP.<> DT.disp pn <-> DT.disp v
dispLBound _pn ZeroB = error "unhandled 'dispLBound ZeroB'"
dispUBound :: PackageName -> UBound -> Disp.Doc
-dispUBound pn (StrictUB v) = Disp.char '<' <> DT.disp pn <-> DT.disp v
-dispUBound pn (NonstrictUB v) = Disp.text "<=" <> DT.disp pn <-> DT.disp v
+dispUBound pn (StrictUB v) = Disp.char '<' PP.<> DT.disp pn <-> DT.disp v
+dispUBound pn (NonstrictUB v) = Disp.text "<=" PP.<> DT.disp pn <-> DT.disp v
dispUBound _pn InfinityB = error "unhandled 'dispUBound Infinity'"
dispDAttr :: DAttr -> Disp.Doc
-dispDAttr (DAttr s u) = dispSlot s <> dispUses u
+dispDAttr (DAttr s u) = dispSlot s PP.<> dispUses u
dep2str :: Int -> Dependency -> String
dep2str start_indent = render . nest start_indent . showDepend
@@ -40,13 +43,13 @@ dep2str_noindent :: Dependency -> String
dep2str_noindent = render . showDepend
(<->) :: Disp.Doc -> Disp.Doc -> Disp.Doc
-a <-> b = a <> Disp.char '-' <> b
+a <-> b = a PP.<> Disp.char '-' PP.<> b
sp :: Disp.Doc
sp = Disp.char ' '
sparens :: Disp.Doc -> Disp.Doc
-sparens doc = Disp.parens (sp <> valign doc <> sp)
+sparens doc = Disp.parens (sp PP.<> valign doc PP.<> sp)
valign :: Disp.Doc -> Disp.Doc
valign d = nest 0 d
@@ -55,24 +58,24 @@ showDepend :: Dependency -> Disp.Doc
showDepend (DependAtom (Atom pn range dattr))
= case range of
-- any version
- DRange ZeroB InfinityB -> DT.disp pn <> dispDAttr dattr
- DRange ZeroB ub -> dispUBound pn ub <> dispDAttr dattr
- DRange lb InfinityB -> dispLBound pn lb <> dispDAttr dattr
+ DRange ZeroB InfinityB -> DT.disp pn PP.<> dispDAttr dattr
+ DRange ZeroB ub -> dispUBound pn ub PP.<> dispDAttr dattr
+ DRange lb InfinityB -> dispLBound pn lb PP.<> dispDAttr dattr
-- TODO: handle >=foo-0 special case
-- TODO: handle =foo-x.y.* special case
DRange lb ub -> showDepend (DependAtom (Atom pn (DRange lb InfinityB) dattr))
- <> Disp.char ' '
- <> showDepend (DependAtom (Atom pn (DRange ZeroB ub) dattr))
- DExact v -> Disp.char '~' <> DT.disp pn <-> DT.disp v { versionRevision = 0 } <> dispDAttr dattr
+ PP.<> Disp.char ' '
+ PP.<> showDepend (DependAtom (Atom pn (DRange ZeroB ub) dattr))
+ DExact v -> Disp.char '~' PP.<> DT.disp pn <-> DT.disp v { versionRevision = 0 } PP.<> dispDAttr dattr
showDepend (DependIfUse u td fd) = valign $ vcat [td_doc, fd_doc]
where td_doc
| is_empty_dependency td = Disp.empty
- | otherwise = DT.disp u <> Disp.char '?' <> sp <> sparens (showDepend td)
+ | otherwise = DT.disp u PP.<> Disp.char '?' PP.<> sp PP.<> sparens (showDepend td)
fd_doc
| is_empty_dependency fd = Disp.empty
- | otherwise = Disp.char '!' <> DT.disp u <> Disp.char '?' <> sp <> sparens (showDepend fd)
-showDepend (DependAnyOf deps) = Disp.text "||" <> sp <> sparens (vcat $ map showDependInAnyOf deps)
+ | otherwise = Disp.char '!' PP.<> DT.disp u PP.<> Disp.char '?' PP.<> sp PP.<> sparens (showDepend fd)
+showDepend (DependAnyOf deps) = Disp.text "||" PP.<> sp PP.<> sparens (vcat $ map showDependInAnyOf deps)
showDepend (DependAllOf deps) = valign $ vcat $ map showDepend deps
-- needs special grouping
diff --git a/Portage/PackageId.hs b/Portage/PackageId.hs
index f97148c..2aa8f0a 100644
--- a/Portage/PackageId.hs
+++ b/Portage/PackageId.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
-- | Portage package identifiers, which unlike Cabal ones include a category.
--
module Portage.PackageId (
@@ -31,6 +33,10 @@ import qualified Data.Char as Char (isAlphaNum, isSpace, toLower)
import Distribution.Text(display)
import System.FilePath ( (</>) )
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
+
newtype Category = Category { unCategory :: String }
deriving (Eq, Ord, Show, Read)
diff --git a/Portage/Use.hs b/Portage/Use.hs
index e193ff6..0f29f08 100644
--- a/Portage/Use.hs
+++ b/Portage/Use.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
module Portage.Use (
-- * main structures
UseFlag(..),
@@ -13,6 +15,10 @@ import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
import qualified Distribution.Text as DT
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
+
-- | Use variable modificator
data UseFlag = UseFlag Use -- ^ no modificator
| E UseFlag -- ^ = modificator (Equiv mark)
diff --git a/Portage/Version.hs b/Portage/Version.hs
index 772343f..d87e9a6 100644
--- a/Portage/Version.hs
+++ b/Portage/Version.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
{-|
Author : Andres Loeh <kosmikus@gentoo.org>
Stability : provisional
@@ -26,6 +28,10 @@ import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
import qualified Data.Char as Char (isAlpha, isDigit)
+#if MIN_VERSION_base(4,11,0)
+import Prelude hiding ((<>))
+#endif
+
data Version = Version { versionNumber :: [Int] -- [1,42,3] ~= 1.42.3
, versionChar :: (Maybe Char) -- optional letter
, versionSuffix :: [Suffix]
diff --git a/hackport.cabal b/hackport.cabal
index a2f2883..e4b557a 100644
--- a/hackport.cabal
+++ b/hackport.cabal
@@ -1,5 +1,5 @@
Name: hackport
-Version: 0.5.5
+Version: 0.5.6
License: GPL
License-file: LICENSE
Author: Henning G√ľnther, Duncan Coutts, Lennart Kolmodin