@@ -35,6 +35,7 @@ import Distribution.Solver.Types.PackagePath
3535import Distribution.Solver.Types.PkgConfigDb (PkgConfigDb , pkgConfigPkgIsPresent )
3636import Distribution.Types.LibraryName
3737import Distribution.Types.PkgconfigVersionRange
38+ import Distribution.Solver.Types.Stage (Staged (.. ), Stage )
3839
3940-- In practice, most constraints are implication constraints (IF we have made
4041-- a number of choices, THEN we also have to ensure that). We call constraints
@@ -88,8 +89,8 @@ import Distribution.Types.PkgconfigVersionRange
8889
8990-- | The state needed during validation.
9091data ValidateState = VS {
91- supportedExt :: Extension -> Bool ,
92- supportedLang :: Language -> Bool ,
92+ supportedExt :: Stage -> Extension -> Bool ,
93+ supportedLang :: Stage -> Language -> Bool ,
9394 presentPkgs :: Maybe (PkgconfigName -> PkgconfigVersionRange -> Bool ),
9495 index :: Index ,
9596
@@ -378,15 +379,19 @@ extractNewDeps v b fa sa = go
378379--
379380-- Either returns a witness of the conflict that would arise during the merge,
380381-- or the successfully extended assignment.
381- extend :: (Extension -> Bool ) -- ^ is a given extension supported
382- -> (Language -> Bool ) -- ^ is a given language supported
383- -> Maybe (PkgconfigName -> PkgconfigVersionRange -> Bool ) -- ^ is a given pkg-config requirement satisfiable
382+ extend :: (Extension -> Bool )
383+ -- ^ is a given extension supported
384+ -> (Language -> Bool )
385+ -- ^ is a given language supported
386+ -> Maybe (PkgconfigName -> PkgconfigVersionRange -> Bool )
387+ -- ^ is a given pkg-config requirement satisfiable
384388 -> [LDep QPN ]
385389 -> PPreAssignment
386390 -> Either Conflict PPreAssignment
387- extend extSupported langSupported pkgPresent newactives ppa = foldM extendSingle ppa newactives
388- where
391+ extend extSupported langSupported pkgPresent newactives ppa =
392+ foldM extendSingle ppa newactives
389393
394+ where
390395 extendSingle :: PPreAssignment -> LDep QPN -> Either Conflict PPreAssignment
391396 extendSingle a (LDep dr (Ext ext )) =
392397 if extSupported ext then Right a
@@ -560,14 +565,13 @@ extendRequiredComponents eqpn available = foldM extendSingle
560565
561566
562567-- | Interface.
563- validateTree :: CompilerInfo -> Maybe PkgConfigDb -> Index -> Tree d c -> Tree d c
568+ validateTree :: Staged CompilerInfo -> Maybe PkgConfigDb -> Index -> Tree d c -> Tree d c
564569validateTree cinfo pkgConfigDb idx t = runValidate (validate t) VS {
565- supportedExt = maybe (const True ) -- if compiler has no list of extensions, we assume everything is supported
566- (\ es -> let s = S. fromList es in \ x -> S. member x s)
567- (compilerInfoExtensions cinfo)
568- , supportedLang = maybe (const True )
569- (flip L. elem ) -- use list lookup because language list is small and no Ord instance
570- (compilerInfoLanguages cinfo)
570+ supportedExt = -- if compiler has no list of extensions, we assume everything is supported
571+ let extSet = fmap (fmap S. fromList . compilerInfoExtensions) cinfo
572+ in maybe (const True ) (flip S. member) . getStage extSet
573+ , supportedLang = let langSet = fmap (fmap S. fromList . compilerInfoLanguages) cinfo
574+ in maybe (const True ) (flip S. member) . getStage langSet
571575 , presentPkgs = pkgConfigPkgIsPresent <$> pkgConfigDb
572576 , index = idx
573577 , saved = M. empty
0 commit comments