Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
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
- data Delimiters
- semantic :: Delimiters
- minor :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters
- patch :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters
- release :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters
- metadata :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters
- identifier :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters
- toBuilder :: Delimiters -> Version -> Builder
- parser :: Delimiters -> Parser Version
Delimiters
data Delimiters Source #
An opaque set representing the seperators used to delimit semantic version components.
Instances
Eq Delimiters Source # | |
Defined in Data.SemVer.Internal (==) :: Delimiters -> Delimiters -> Bool # (/=) :: Delimiters -> Delimiters -> Bool # | |
Ord Delimiters Source # | |
Defined in Data.SemVer.Internal compare :: Delimiters -> Delimiters -> Ordering # (<) :: Delimiters -> Delimiters -> Bool # (<=) :: Delimiters -> Delimiters -> Bool # (>) :: Delimiters -> Delimiters -> Bool # (>=) :: Delimiters -> Delimiters -> Bool # max :: Delimiters -> Delimiters -> Delimiters # min :: Delimiters -> Delimiters -> Delimiters # | |
Show Delimiters Source # | |
Defined in Data.SemVer.Internal showsPrec :: Int -> Delimiters -> ShowS # show :: Delimiters -> String # showList :: [Delimiters] -> ShowS # | |
NFData Delimiters Source # | |
Defined in Data.SemVer.Internal rnf :: Delimiters -> () # |
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.