semver-0.3.3.1: Representation, manipulation, and de/serialisation of Semantic Versions.

Safe HaskellNone
LanguageHaskell2010

Data.SemVer.Delimited

Contents

Description

A set of delimiters can be used to encode/decode a Version and specify alternative serialisation strategies.

Lenses can be used to modify the default delimiter set, as in the following example - using alpha characters to encode the version as a valid DNS CNAME (assuming operators from lens or lens-family-core):

let Right v = fromText "1.2.3+40"
let alpha = semantic & major .~ 'm' & patch .~ 'p' & release .~ 'r' & metadata .~ 'd' & identifier .~ 'i'

Data.Text.Lazy.Builder.toLazyText ("app01-" <> toBuilder alpha v <> ".dmz.internal")

Would result in the following Text:

app01-1m2p3d40.dmz.internal

Using the same Delimiters set with parser would ensure correct decoding behaviour.

Synopsis

Delimiters

data Delimiters Source

An opaque set representing the seperators used to delimit semantic version components.

Constructor

semantic :: Delimiters Source

The default set of delimiters used in the semantic version specification.

Example: Given exhaustive version components would result in the following hypothetical version:

1.2.3-alpha.1+sha.exp.12ab3d9

Lenses

minor :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters Source

Lens for the minor version delimiter. Default: .

patch :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters Source

Lens for the patch version delimiter. Default: .

release :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters Source

Lens for the release component delimiter. Default: -

metadata :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters Source

Lens for the metadata component delimiter. Default: +

identifier :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters Source

Lens for the individual identifier delimiter. Default: .

Encoding

toBuilder :: Delimiters -> Version -> Builder Source

Convert a Version to a Builder using the specified Delimiters set.

Decoding

parser :: Delimiters -> Parser Version Source

A greedy attoparsec Parser using the specified Delimiters set which requires the entire Text input to match.