@@ -15,7 +15,8 @@ import Distribution.Compat.Prelude
15
15
import Prelude ()
16
16
17
17
import Distribution.Version
18
- (VersionRange , anyVersion , notThisVersion , simplifyVersionRange , thisVersion )
18
+ (VersionRange , anyVersion ,notThisVersion , simplifyVersionRange , thisVersion )
19
+ import Distribution.Types.VersionRange (isAnyVersionLight )
19
20
20
21
import Distribution.CabalSpecVersion
21
22
import Distribution.Compat.CharParsing (char , spaces )
@@ -76,8 +77,12 @@ instance Structured Dependency
76
77
instance NFData Dependency where rnf = genericRnf
77
78
78
79
instance Pretty Dependency where
79
- pretty (Dependency name ver sublibs) = withSubLibs (pretty name) <+> pretty ver
80
+ pretty (Dependency name ver sublibs) = withSubLibs (pretty name) <+> pver
80
81
where
82
+ -- TODO: change to isAnyVersion after #6736
83
+ pver | isAnyVersionLight ver = PP. empty
84
+ | otherwise = pretty ver
85
+
81
86
withSubLibs doc
82
87
| sublibs == mainLib = doc
83
88
| otherwise = doc <<>> PP. colon <<>> PP. braces prettySublibs
@@ -90,13 +95,13 @@ instance Pretty Dependency where
90
95
-- |
91
96
--
92
97
-- >>> simpleParsec "mylib:sub" :: Maybe Dependency
93
- -- Just (Dependency (PackageName "mylib") AnyVersion (fromList [LSubLibName (UnqualComponentName "sub")]))
98
+ -- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromList [LSubLibName (UnqualComponentName "sub")]))
94
99
--
95
100
-- >>> simpleParsec "mylib:{sub1,sub2}" :: Maybe Dependency
96
- -- Just (Dependency (PackageName "mylib") AnyVersion (fromList [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]))
101
+ -- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromList [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]))
97
102
--
98
103
-- >>> simpleParsec "mylib:{ sub1 , sub2 }" :: Maybe Dependency
99
- -- Just (Dependency (PackageName "mylib") AnyVersion (fromList [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]))
104
+ -- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromList [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]))
100
105
--
101
106
-- >>> simpleParsec "mylib:{ sub1 , sub2 } ^>= 42" :: Maybe Dependency
102
107
-- Just (Dependency (PackageName "mylib") (MajorBoundVersion (mkVersion [42])) (fromList [LSubLibName (UnqualComponentName "sub1"),LSubLibName (UnqualComponentName "sub2")]))
@@ -105,9 +110,9 @@ instance Pretty Dependency where
105
110
-- Just (Dependency (PackageName "mylib") (MajorBoundVersion (mkVersion [42])) (fromList []))
106
111
--
107
112
-- >>> traverse_ print (map simpleParsec ["mylib:mylib", "mylib:{mylib}", "mylib:{mylib,sublib}" ] :: [Maybe Dependency])
108
- -- Just (Dependency (PackageName "mylib") AnyVersion (fromList [LMainLibName]))
109
- -- Just (Dependency (PackageName "mylib") AnyVersion (fromList [LMainLibName]))
110
- -- Just (Dependency (PackageName "mylib") AnyVersion (fromList [LMainLibName,LSubLibName (UnqualComponentName "sublib")]))
113
+ -- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromList [LMainLibName]))
114
+ -- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromList [LMainLibName]))
115
+ -- Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromList [LMainLibName,LSubLibName (UnqualComponentName "sublib")]))
111
116
--
112
117
-- Spaces around colon are not allowed:
113
118
--
@@ -117,7 +122,7 @@ instance Pretty Dependency where
117
122
-- Sublibrary syntax is accepted since @cabal-version: 3.0@
118
123
--
119
124
-- >>> map (`simpleParsec'` "mylib:sub") [CabalSpecV2_4, CabalSpecV3_0] :: [Maybe Dependency]
120
- -- [Nothing,Just (Dependency (PackageName "mylib") AnyVersion (fromList [LSubLibName (UnqualComponentName "sub")]))]
125
+ -- [Nothing,Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromList [LSubLibName (UnqualComponentName "sub")]))]
121
126
--
122
127
instance Parsec Dependency where
123
128
parsec = do
@@ -157,7 +162,7 @@ mainLib = Set.singleton LMainLibName
157
162
instance Described Dependency where
158
163
describe _ = REAppend
159
164
[ RENamed " pkg-name" (describe (Proxy :: Proxy PackageName ))
160
- , REOpt $
165
+ , REOpt $
161
166
reChar ' :'
162
167
<> REUnion
163
168
[ reUnqualComponent
@@ -168,7 +173,7 @@ instance Described Dependency where
168
173
, REMunch reSpacedComma reUnqualComponent
169
174
, RESpaces
170
175
, reChar ' }'
171
- ]
176
+ ]
172
177
]
173
178
-- TODO: RESpaces1 should be just RESpaces, but we are able
174
179
-- to generate non-parseable strings without mandatory space
0 commit comments