Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data PrereleaseTag
- newtype PrereleaseTags = PrereleaseTags [PrereleaseTag]
- type BuildMetaData = [Text]
- data SemVer = SemVer {
- svMajor :: !Int
- svMinor :: !Int
- svPatch :: !Int
- svTags :: !PrereleaseTags
- svBuildMetadata :: !BuildMetaData
- data SemVerRange
- = Eq SemVer
- | Gt SemVer
- | Lt SemVer
- | Geq SemVer
- | Leq SemVer
- | And SemVerRange SemVerRange
- | Or SemVerRange SemVerRange
- versionsOf :: SemVerRange -> [SemVer]
- semver :: Int -> Int -> Int -> SemVer
- semver' :: Int -> Int -> Int -> PrereleaseTags -> SemVer
- semver'' :: Int -> Int -> Int -> PrereleaseTags -> BuildMetaData -> SemVer
- toTuple :: SemVer -> (Int, Int, Int)
- tuplesOf :: SemVerRange -> [(Int, Int, Int)]
- rangePrereleaseTags :: SemVerRange -> PrereleaseTags
- sharedTags :: SemVerRange -> Maybe PrereleaseTags
- anyVersion :: SemVerRange
- renderSV :: SemVer -> Text
- matches :: SemVerRange -> SemVer -> Bool
- matchesTags :: SemVerRange -> [PrereleaseTag] -> [PrereleaseTag] -> Bool
- bestMatch :: SemVerRange -> [SemVer] -> Either String SemVer
- type Parser = ParsecT String () Identity
- data Wildcard
- wildcardToSemver :: Wildcard -> SemVer
- wildcardToRange :: Wildcard -> SemVerRange
- tildeToRange :: Wildcard -> SemVerRange
- caratToRange :: Wildcard -> SemVerRange
- hyphenatedRange :: Wildcard -> Wildcard -> SemVerRange
- parse :: Parser a -> Text -> Either ParseError a
- parseFull :: Parser a -> Text -> Either ParseError a
- spaces :: Parser String
- spaces1 :: Parser String
- sstring :: String -> Parser String
- schar :: Char -> Parser Char
- lexeme :: Parser a -> Parser a
- pInt :: Parser Int
- pInt' :: Parser Int
- parseSemVerRange :: Text -> Either ParseError SemVerRange
- parseSemVer :: Text -> Either ParseError SemVer
- pSemVer :: Parser SemVer
- pVersionComp :: Parser SemVerRange
- cmp :: Parser String
- pSemVerRangeSingle :: Parser SemVerRange
- pJoinedSemVerRange :: Parser SemVerRange
- pHyphen :: Parser SemVerRange
- pWildCard :: Parser Wildcard
- pTildeRange :: Parser SemVerRange
- pCaratRange :: Parser SemVerRange
- pSemVerRange :: Parser SemVerRange
- fromHaskellVersion :: Version -> Either Text SemVer
- matchText :: Text -> Text -> Either Text Bool
Documentation
data PrereleaseTag Source #
Prerelease tags can either be numbers or text.
newtype PrereleaseTags Source #
type BuildMetaData = [Text] Source #
A SemVer has major, minor and patch versions, and zero or more pre-release version tags.
SemVer | |
|
data SemVerRange Source #
A range specifies bounds on a semver.
Eq SemVer infixl 4 | Exact equality |
Gt SemVer infixl 4 | Greater than |
Lt SemVer infixl 4 | Less than |
Geq SemVer infixl 4 | Greater than or equal to |
Leq SemVer infixl 4 | Less than or equal to |
And SemVerRange SemVerRange infixl 3 | Conjunction |
Or SemVerRange SemVerRange infixl 3 | Disjunction |
versionsOf :: SemVerRange -> [SemVer] Source #
Pull all of the concrete versions out of a range.
semver'' :: Int -> Int -> Int -> PrereleaseTags -> BuildMetaData -> SemVer Source #
Create a SemVer with tags and metadata.
rangePrereleaseTags :: SemVerRange -> PrereleaseTags Source #
Get all of the prerelease tags from a version range.
sharedTags :: SemVerRange -> Maybe PrereleaseTags Source #
Get the range prerelease tags if they're all the same; otherwise Nothing.
anyVersion :: SemVerRange Source #
Satisfies any version.
matches :: SemVerRange -> SemVer -> Bool infixl 2 Source #
Returns whether a given semantic version matches a range. Note that there are special cases when there are prerelease tags. For details see https://github.com/npm/node-semver#prerelease-tags. matches :: SemVerRange -> SemVer -> Bool matches range version = case (sharedTags range, svTags version) of -- This is the simple case, where neither the range nor the version has given -- prerelease tags. Then we can just do regular predicate calculus. (Nothing, PrereleaseTags []) -> matchesSimple range version _ -> undefined -- (Just rTags, PrereleaseTags vTags) -- | rTags == vTags -> matchesSimple range version -- | tuplesOf range /= [toTuple version] -> False -- | otherwise -> matchesTags range rTags vTags -- (_, _) -> False
Simple predicate calculus matching, doing AND and OR combination with numerical comparison.
matchesTags :: SemVerRange -> [PrereleaseTag] -> [PrereleaseTag] -> Bool Source #
Given a range and two sets of tags, the first being a bound on the second, uses the range to compare the tags and see if they match.
bestMatch :: SemVerRange -> [SemVer] -> Either String SemVer Source #
Gets the highest-matching semver in a range.
A partially specified semantic version. Implicitly defines
a range of acceptable versions, as seen in wildcardToRange
.
wildcardToSemver :: Wildcard -> SemVer Source #
Fills in zeros in a wildcard.
wildcardToRange :: Wildcard -> SemVerRange Source #
Translates a wildcard (partially specified version) to a range. Ex: 2 := >=2.0.0 <3.0.0 Ex: 1.2.x := 1.2 := >=1.2.0 <1.3.0
tildeToRange :: Wildcard -> SemVerRange Source #
Translates a ~wildcard to a range. Ex: ~1.2.3 := >=1.2.3 :==1.2.3 <1.3.0
caratToRange :: Wildcard -> SemVerRange Source #
Translates a ^wildcard to a range. Ex: ^1.2.x := >=1.2.0 <2.0.0
hyphenatedRange :: Wildcard -> Wildcard -> SemVerRange Source #
Translates two hyphenated wildcards to an actual range. Ex: 1.2.3 - 2.3.4 := >=1.2.3 <=2.3.4 Ex: 1.2 - 2.3.4 := >=1.2.0 <=2.3.4 Ex: 1.2.3 - 2 := >=1.2.3 <3.0.0
parse :: Parser a -> Text -> Either ParseError a Source #
Given a parser and a string, attempts to parse the string.
parseSemVerRange :: Text -> Either ParseError SemVerRange Source #
Parse a string as a version range, or return an error.
parseSemVer :: Text -> Either ParseError SemVer Source #
Parse a string as an explicit version, or return an error.
pSemVerRangeSingle :: Parser SemVerRange Source #
Parses versions with an explicit range qualifier (gt, lt, etc).
pJoinedSemVerRange :: Parser SemVerRange Source #
Parses semantic version ranges joined with Ands and Ors.
pHyphen :: Parser SemVerRange Source #
Parses a hyphenated range.
pWildCard :: Parser Wildcard Source #
Parses a "wildcard" (which is a possibly partial semantic version).
pTildeRange :: Parser SemVerRange Source #
Parses a tilde range (~1.2.3).
pCaratRange :: Parser SemVerRange Source #
Parses a carat range (^1.2.3).
pSemVerRange :: Parser SemVerRange Source #
Top-level parser. Parses a semantic version range.