On 2011/1/2 Peter Simons <[email protected]> wrote: > Rémy Oudompheng writes: > > > https://github.com/archhaskell/cabal2arch/issues#issue/19. > > the gist of this issue is that "parsec >= 3.0 || == 2.1.*" is translated to > "parsec>=3.0", which is just plain wrong. Now, wouldn't it be easiest to > modify cabal2arch so that it translates that specification to "parsec>=2.1"? > A straight-forward algorithm to accomplish that would be to use the *lowest* > version bound in these kinds of alternatives. Right now, cabal2arch appears > to be using the *first* version bound, which is not exactly optimal. > > Am I missing something?
Dependencies are expressed as a union of intervals : here [2.1, 2.2) union [3.0, infinity) (square brackets mean inclusive, parentheses mean exclusive bounds). * how should multiple intervals be treated ? I currently use the last one, Peter suggests to use the first one, maybe we should use the convex hull of possible dependencies ? * when the dependency spec is reduced to a single interval [a,b] should we output >=a or <=b ? if the interval is unbounded then there is no problem. I can suggest the attached patch, that would lead to the output you want. -- Rémy.
From c13b096f5f75e1f21e6a6f91d13c498e763c3cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Oudompheng?= <[email protected]> Date: Sun, 2 Jan 2011 12:11:36 +0100 Subject: [PATCH 1/2] Less restrictive version requirements in output --- Distribution/ArchLinux/PkgBuild.hs | 31 +++++++++++++++++++------------ 1 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Distribution/ArchLinux/PkgBuild.hs b/Distribution/ArchLinux/PkgBuild.hs index 81d804e..bf3c2e1 100644 --- a/Distribution/ArchLinux/PkgBuild.hs +++ b/Distribution/ArchLinux/PkgBuild.hs @@ -180,29 +180,36 @@ instance Text ArchOptions where -- the PKGBUILD version spec is less expressive than cabal, we can -- only handle simple intervals like (0,v) or (v,+infty) mydisp :: VersionInterval -> Doc -mydisp (LowerBound v InclusiveBound, NoUpperBound) = if v==zeroVersion then empty else text ">=" <> disp v -mydisp (LowerBound v ExclusiveBound, NoUpperBound) = text ">" <> disp v -mydisp (_, UpperBound v boundType) = text symbol <> disp v - where symbol = if boundType == InclusiveBound then "<=" else "<" +mydisp (LowerBound v t, NoUpperBound) = + case t of + InclusiveBound -> if v==zeroVersion then empty else text ">=" <> disp v + ExclusiveBound -> text ">" <> disp v +mydisp (LowerBound v1 t1, UpperBound v2 t2) = text symbol <> disp v2 + where symbol | v1 == v2 = "=" + | t2 == InclusiveBound = "<=" + | t2 == ExclusiveBound = "<" zeroVersion :: Version zeroVersion = Version [0] [] instance Text ArchDep where disp (ArchDep (Dependency name ver)) = - disp name <> mydisp2 intervals + disp name <> mydisp (collapse intervals) where intervals = asVersionIntervals ver strName = display name -- >= (greater than or equal to), <= (less than or -- equal to), = (equal to), > (greater than), or < - mydisp2 l | l == [] = trace ("WARNING: version requirement for " ++ - strName ++ " is logically impossible.") empty - | tail l == [] = mydisp $ head l - -- If there are multiple possible ranges, take only latest versions - | otherwise = trace ("WARNING: multiple version ranges specified for " ++ - strName ++ " using only the last one.") $ mydisp $ last l - + -- + -- Reduce intervals to a single one + collapse l | null l = trace ("WARNING: version requirement for " ++ + strName ++ " is logically impossible.") + (head $ asVersionIntervals anyVersion) + | null $ tail l = head l + -- If there are multiple possible ranges, take the interval that contains all + | otherwise = trace ("WARNING: multiple version ranges specified for " ++ + strName ++ " using only the last one.") + (fst $ head l, snd $ last l) parse = undefined -- -- 1.7.3.4
_______________________________________________ arch-haskell mailing list [email protected] http://www.haskell.org/mailman/listinfo/arch-haskell
