-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | An implementation of semver and semantic version ranges.
--
-- An implementation of semver and semantic version ranges.
@package semver-range
@version 0.2.2
module Data.SemVer
-- | Prerelease tags can either be numbers or text.
data PrereleaseTag
IntTag :: Int -> PrereleaseTag
TextTag :: Text -> PrereleaseTag
newtype PrereleaseTags
PrereleaseTags :: [PrereleaseTag] -> PrereleaseTags
type BuildMetaData = [Text]
-- | A SemVer has major, minor and patch versions, and zero or more
-- pre-release version tags.
data SemVer
SemVer :: !Int -> !Int -> !Int -> !PrereleaseTags -> !BuildMetaData -> SemVer
[svMajor] :: SemVer -> !Int
[svMinor] :: SemVer -> !Int
[svPatch] :: SemVer -> !Int
[svTags] :: SemVer -> !PrereleaseTags
[svBuildMetadata] :: SemVer -> !BuildMetaData
-- | Define an Ord instance which ignores the buildMetaData.
-- | A range specifies bounds on a semver.
data SemVerRange
-- | Exact equality
Eq :: SemVer -> SemVerRange
-- | Greater than
Gt :: SemVer -> SemVerRange
-- | Less than
Lt :: SemVer -> SemVerRange
-- | Greater than or equal to
Geq :: SemVer -> SemVerRange
-- | Less than or equal to
Leq :: SemVer -> SemVerRange
-- | Conjunction
And :: SemVerRange -> SemVerRange -> SemVerRange
-- | Disjunction
Or :: SemVerRange -> SemVerRange -> SemVerRange
-- | Pull all of the concrete versions out of a range.
versionsOf :: SemVerRange -> [SemVer]
-- | Create a SemVer with no version tags.
semver :: Int -> Int -> Int -> SemVer
-- | Create a SemVer with tags
semver' :: Int -> Int -> Int -> PrereleaseTags -> SemVer
-- | Create a SemVer with tags and metadata.
semver'' :: Int -> Int -> Int -> PrereleaseTags -> BuildMetaData -> SemVer
-- | Get only the version tuple from a semver.
toTuple :: SemVer -> (Int, Int, Int)
-- | Get a list of tuples from a version range.
tuplesOf :: SemVerRange -> [(Int, Int, Int)]
-- | Get all of the prerelease tags from a version range.
rangePrereleaseTags :: SemVerRange -> PrereleaseTags
-- | Get the range prerelease tags if they're all the same; otherwise
-- Nothing.
sharedTags :: SemVerRange -> Maybe PrereleaseTags
-- | Satisfies any version.
anyVersion :: SemVerRange
-- | Render a semver as Text.
renderSV :: SemVer -> Text
-- | 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.
matches :: SemVerRange -> SemVer -> Bool
infixl 2 `matches`
-- | 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.
matchesTags :: SemVerRange -> [PrereleaseTag] -> [PrereleaseTag] -> Bool
-- | Gets the highest-matching semver in a range.
bestMatch :: SemVerRange -> [SemVer] -> Either String SemVer
type Parser = ParsecT String () Identity
-- | A partially specified semantic version. Implicitly defines a range of
-- acceptable versions, as seen in wildcardToRange.
data Wildcard
Any :: Wildcard
One :: Int -> Wildcard
Two :: Int -> Int -> Wildcard
Full :: SemVer -> Wildcard
-- | Fills in zeros in a wildcard.
wildcardToSemver :: Wildcard -> SemVer
-- | 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
wildcardToRange :: Wildcard -> SemVerRange
-- | Translates a ~wildcard to a range. Ex: ~1.2.3 := >=1.2.3
-- :==1.2.3 <1.3.0
tildeToRange :: Wildcard -> SemVerRange
-- | Translates a ^wildcard to a range. Ex: ^1.2.x := >=1.2.0 <2.0.0
caratToRange :: Wildcard -> SemVerRange
-- | 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
hyphenatedRange :: Wildcard -> Wildcard -> SemVerRange
-- | Given a parser and a string, attempts to parse the string.
parse :: Parser a -> Text -> Either ParseError a
parseFull :: Parser a -> Text -> Either ParseError a
-- | Consumes any spaces (not other whitespace).
spaces :: Parser String
-- | Consumes at least one space (not other whitespace).
spaces1 :: Parser String
-- | Parses the given string and any trailing spaces.
sstring :: String -> Parser String
-- | Parses the given character and any trailing spaces.
schar :: Char -> Parser Char
-- | Parses p and any trailing spaces.
lexeme :: Parser a -> Parser a
-- | Parses an integer.
pInt :: Parser Int
-- | Parses an integer without consuming trailing spaces.
pInt' :: Parser Int
-- | Parse a string as a version range, or return an error.
parseSemVerRange :: Text -> Either ParseError SemVerRange
-- | Parse a string as an explicit version, or return an error.
parseSemVer :: Text -> Either ParseError SemVer
-- | Parses a semantic version.
pSemVer :: Parser SemVer
pVersionComp :: Parser SemVerRange
-- | Parses a comparison operator.
cmp :: Parser String
-- | Parses versions with an explicit range qualifier (gt, lt, etc).
pSemVerRangeSingle :: Parser SemVerRange
-- | Parses semantic version ranges joined with Ands and Ors.
pJoinedSemVerRange :: Parser SemVerRange
-- | Parses a hyphenated range.
pHyphen :: Parser SemVerRange
-- | Parses a "wildcard" (which is a possibly partial semantic version).
pWildCard :: Parser Wildcard
-- | Parses a tilde range (~1.2.3).
pTildeRange :: Parser SemVerRange
-- | Parses a carat range (^1.2.3).
pCaratRange :: Parser SemVerRange
-- | Top-level parser. Parses a semantic version range.
pSemVerRange :: Parser SemVerRange
-- | Parse a semver from a haskell version. There must be exactly three
-- numbers in the versionBranch field.
fromHaskellVersion :: Version -> Either Text SemVer
-- | Parses the first argument as a range and the second argument as a
-- semver, and returns whether they match.
matchText :: Text -> Text -> Either Text Bool