@@ -7,13 +7,12 @@ module Distribution.Solver.Modular.Message (
7
7
showMessages
8
8
) where
9
9
10
- import Data.Maybe (isJust )
11
10
import qualified Data.List as L
12
11
import Data.Map (Map )
13
12
import qualified Data.Map as M
14
13
import Data.Set (Set )
15
14
import qualified Data.Set as S
16
- import Data.Maybe (catMaybes , mapMaybe )
15
+ import Data.Maybe (catMaybes , mapMaybe , isJust )
17
16
import Prelude hiding (pi )
18
17
19
18
import Distribution.Pretty (prettyShow ) -- from Cabal
@@ -236,61 +235,41 @@ blurbOption :: ProgressAction -> QPN -> POption -> String
236
235
blurbOption a q p = blurb a ++ showOption q p
237
236
238
237
blurbOptions :: ProgressAction -> QPN -> [POption ] -> String
239
- blurbOptions a q ps = blurb a ++ showIsOrVs q (tryVs ps)
238
+ blurbOptions a q ps = blurb a ++ showOptions q ps
240
239
241
240
showOption :: QPN -> POption -> String
242
241
showOption qpn@ (Q _pp pn) (POption i linkedTo) =
243
242
case linkedTo of
244
243
Nothing -> showPI (PI qpn i) -- Consistent with prior to POption
245
244
Just pp' -> showQPN qpn ++ " ~>" ++ showPI (PI (Q pp' pn) i)
246
245
247
- -- | A list of versions, or a list of instances.
248
- data IsOrVs = Is [POption ] | Vs [Ver ] deriving Show
249
-
250
- -- | Try to convert a list of options to a list of versions, or a list of
251
- -- instances if any of the options is linked or installed. Singleton lists or
252
- -- empty lists are always converted to Is.
253
- -- >>> tryVs [v0, v1]
254
- -- Vs [mkVersion [0],mkVersion [1]]
255
- -- >>> tryVs [v0]
256
- -- Is [POption (I (mkVersion [0]) InRepo) Nothing]
257
- -- >>> tryVs [i0, i1]
258
- -- Is [POption (I (mkVersion [0]) (Inst (UnitId "foo-bar-0-inplace"))) Nothing,POption (I (mkVersion [1]) (Inst (UnitId "foo-bar-1-inplace"))) Nothing]
259
- -- >>> tryVs [i0, v1]
260
- -- Is [POption (I (mkVersion [0]) (Inst (UnitId "foo-bar-0-inplace"))) Nothing,POption (I (mkVersion [1]) InRepo) Nothing]
261
- -- >>> tryVs [v0, i1]
262
- -- Is [POption (I (mkVersion [0]) InRepo) Nothing,POption (I (mkVersion [1]) (Inst (UnitId "foo-bar-1-inplace"))) Nothing]
263
- -- >>> tryVs [i0]
264
- -- Is [POption (I (mkVersion [0]) (Inst (UnitId "foo-bar-0-inplace"))) Nothing]
265
- -- >>> tryVs []
266
- -- Is []
267
- tryVs :: [POption ] -> IsOrVs
268
- tryVs xs@ [] = Is xs
269
- tryVs xs@ [_] = Is xs
270
- tryVs xs
271
- | any (\ (POption (instI -> b0) (isJust -> b1)) -> b0 || b1) xs = Is xs
272
- | otherwise =
273
- let (vs, is) = L. partition ((== InRepo ) . snd ) [(v, l) | POption i _ <- xs, let I v l = i]
274
- in if null is then Vs (fst `map` vs) else Is xs
275
-
276
- -- | Shows a list of versions in a human-friendly way, abbreviated. Shows a list
277
- -- of instances in full.
278
- -- >>> showIsOrVs foobarQPN $ tryVs [v0, v1]
246
+ -- | Shows a mixed list of instances and versions in a human-friendly way,
247
+ -- abbreviated.
248
+ -- >>> showOptions foobarQPN [v0, v1]
279
249
-- "foo-bar; 0, 1"
280
- -- >>> showIsOrVs foobarQPN $ tryVs [v0]
250
+ -- >>> showOptions foobarQPN [v0]
281
251
-- "foo-bar-0"
282
- -- >>> showIsOrVs foobarQPN $ tryVs [i0, i1]
283
- -- "foo-bar- 0/installed-inplace, foo-bar- 1/installed-inplace"
284
- -- >>> showIsOrVs foobarQPN $ tryVs [i0, v1]
285
- -- "foo-bar- 0/installed-inplace, foo-bar- 1"
286
- -- >>> showIsOrVs foobarQPN $ tryVs [v0, i1]
287
- -- "foo-bar- 0, foo-bar- 1/installed-inplace"
288
- -- >>> showIsOrVs foobarQPN $ tryVs []
252
+ -- >>> showOptions foobarQPN [i0, i1]
253
+ -- "foo-bar; 0/installed-inplace, 1/installed-inplace"
254
+ -- >>> showOptions foobarQPN [i0, v1]
255
+ -- "foo-bar; 0/installed-inplace, 1"
256
+ -- >>> showOptions foobarQPN [v0, i1]
257
+ -- "foo-bar; 0, 1/installed-inplace"
258
+ -- >>> showOptions foobarQPN []
289
259
-- "unexpected empty list of versions"
290
- showIsOrVs :: QPN -> IsOrVs -> String
291
- showIsOrVs _ (Is [] ) = " unexpected empty list of versions"
292
- showIsOrVs q (Is xs) = L. intercalate " , " (showOption q `map` xs)
293
- showIsOrVs q (Vs xs) = showQPN q ++ " ; " ++ L. intercalate " , " (showVer `map` xs)
260
+ -- >>> showOptions foobarQPN [k1, k2]
261
+ -- "foo-bar; foo-bar~>bazqux.foo-bar-1, foo-bar~>bazqux.foo-bar-2"
262
+ -- >>> showOptions foobarQPN [v0, i1, k2]
263
+ -- "foo-bar; 0, 1/installed-inplace, foo-bar~>bazqux.foo-bar-2"
264
+ showOptions :: QPN -> [POption ] -> String
265
+ showOptions _ [] = " unexpected empty list of versions"
266
+ showOptions q [x] = showOption q x
267
+ showOptions q xs = showQPN q ++ " ; " ++ (L. intercalate " , "
268
+ [if isJust linkedTo
269
+ then showOption q x
270
+ else showI i -- Don't show the package, just the version
271
+ | x@ (POption i linkedTo) <- xs
272
+ ])
294
273
295
274
showGR :: QGoalReason -> String
296
275
showGR UserGoal = " (user goal)"
@@ -356,8 +335,12 @@ showConflictingDep (ConflictingDep dr (PkgComponent qpn comp) ci) =
356
335
-- >>> import Distribution.Solver.Types.PackagePath
357
336
-- >>> import Distribution.Types.Version
358
337
-- >>> import Distribution.Types.UnitId
359
- -- >>> let foobarQPN = Q (PackagePath DefaultNamespace QualToplevel) (mkPackageName "foo-bar")
338
+ -- >>> let foobarPN = PackagePath DefaultNamespace QualToplevel
339
+ -- >>> let bazquxPN = PackagePath (Independent $ mkPackageName "bazqux") QualToplevel
340
+ -- >>> let foobarQPN = Q foobarPN (mkPackageName "foo-bar")
360
341
-- >>> let v0 = POption (I (mkVersion [0]) InRepo) Nothing
361
342
-- >>> let v1 = POption (I (mkVersion [1]) InRepo) Nothing
362
343
-- >>> let i0 = POption (I (mkVersion [0]) (Inst $ mkUnitId "foo-bar-0-inplace")) Nothing
363
344
-- >>> let i1 = POption (I (mkVersion [1]) (Inst $ mkUnitId "foo-bar-1-inplace")) Nothing
345
+ -- >>> let k1 = POption (I (mkVersion [1]) InRepo) (Just bazquxPN)
346
+ -- >>> let k2 = POption (I (mkVersion [2]) InRepo) (Just bazquxPN)
0 commit comments