Skip to content

Commit

Permalink
Support the Cabal set syntax for versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleidukos committed Mar 5, 2023
1 parent 09acbfb commit 1c450a9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/Extract.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ extractTestedWith :: GenericPackageDescription -> Vector Version
extractTestedWith genericPackageDescription =
Vector.fromList genericPackageDescription.packageDescription.testedWith
& Vector.filter (\(flavour, _) -> flavour == GHC)
& expandUnionVersionRanges
& Vector.filter (\(_, versionRange) -> isExactVersion versionRange)
& Vector.map (\(flavour, ThisVersion version) -> (flavour, version))
& Vector.map snd
Expand All @@ -69,3 +70,17 @@ isExactVersion _ = False

logAttention :: (IOE :> es) => Text -> Eff es ()
logAttention message = liftIO $ BS.hPutStrLn stdout $ Text.encodeUtf8 message

expandUnionVersionRanges :: Vector (CompilerFlavor, VersionRange) -> Vector (CompilerFlavor, VersionRange)
expandUnionVersionRanges ranges =
Vector.concatMap
( \(f, range) ->
let expandedVersions = expandUnionVersionRange range
in Vector.map (\v -> (f, v)) expandedVersions
)
ranges

expandUnionVersionRange :: VersionRange -> Vector VersionRange
expandUnionVersionRange (ThisVersion v) = Vector.singleton (ThisVersion v)
expandUnionVersionRange (UnionVersionRanges r1 r2) = expandUnionVersionRange r1 <> expandUnionVersionRange r2
expandUnionVersionRange _ = Vector.empty

0 comments on commit 1c450a9

Please sign in to comment.