ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Version

Description

Version identity and ecosystem ordering. Wire text remains verbatim. Advisory identity uses renderVersionKey. Opaque keys carry parsed versions under bounded ecosystem grammars.

Synopsis

Versions

data Version Source #

The raw text as published, plus its ordering key when it parses. No Ord: compare with compareVersions.

Instances

Instances details
Show Version Source # 
Instance details

Defined in Ecluse.Core.Version

Eq Version Source # 
Instance details

Defined in Ecluse.Core.Version

Methods

(==) :: Version -> Version -> Bool #

(/=) :: Version -> Version -> Bool #

versionKey :: Version -> Maybe VersionKey Source #

The canonical ordering key, or Nothing when the text did not parse for its ecosystem, so ordering rules abstain.

versionKeyIn :: Ecosystem -> Version -> Maybe VersionKey Source #

The key mkVersion builds under an ecosystem's grammar, reusing the carried key when it is that ecosystem's and parsing otherwise.

mkVersion :: Ecosystem -> Text -> Version Source #

Build a Version with its evaluated key. An unparseable version stays, keyless, so a parser gap drops nothing.

renderVersion :: Version -> Text Source #

Render a version in wire form: the raw text, verbatim as published.

releaseIdentity :: Version -> Text Source #

The spelling a registry treats as one release. Cargo ignores build metadata, and other ecosystems keep the raw text.

compareVersions :: Version -> Version -> Maybe Ordering Source #

Compare by canonical keys. Nothing when either version has no key, so an ordering rule abstains.

Canonical ordering keys

data VersionKey Source #

The canonical, comparable form of a version. It is opaque and built only by parsing, so no comparator sees non-canonical input.

parseVersionKey :: Ecosystem -> Text -> Either VersionError VersionKey Source #

Parse version text under its ecosystem's grammar. The key's Ord is meaningful only within one ecosystem.

parseAdvisoryVersionKey :: Ecosystem -> Text -> Either VersionError VersionKey Source #

Parse an advisory spelling, accepting one npm v prefix within the raw length bound.

renderVersionKey :: VersionKey -> Text Source #

Render canonical advisory identity, retaining semver build metadata.

newtype VersionError Source #

Why a version string failed to parse.

Constructors

VersionError 

Instances

Instances details
Show VersionError Source # 
Instance details

Defined in Ecluse.Core.Version

Eq VersionError Source # 
Instance details

Defined in Ecluse.Core.Version

isStable :: VersionKey -> Bool Source #

Whether a version is a final release under its ecosystem's grammar.

Canonical PEP 440 spelling

canonicalPep440 :: Text -> Maybe Version Source #

Build the canonical PEP 440 spelling used to merge equivalent PyPI releases.

Resolving dist-tags.latest

selectLatest :: Maybe Version -> [Version] -> Maybe Version Source #

Resolve dist-tags.latest to a survivor, keeping a surviving chosen so a prerelease never displaces the maintainer's tag.