Safe Haskell | None |
---|---|
Language | Haskell2010 |
An implementation of the Semantic Versioning specification located at http://semver.org.
A canonical Version
type and functions representing behaviour as outlined
in the specification are defined alongside additional lenses, traversals,
common manipulations, and serialisation primitives.
- data Version
- version :: Int -> Int -> Int -> [Identifier] -> [Identifier] -> Version
- initial :: Version
- major :: Functor f => (Int -> f Int) -> Version -> f Version
- minor :: Functor f => (Int -> f Int) -> Version -> f Version
- patch :: Functor f => (Int -> f Int) -> Version -> f Version
- release :: Functor f => ([Identifier] -> f [Identifier]) -> Version -> f Version
- metadata :: Functor f => ([Identifier] -> f [Identifier]) -> Version -> f Version
- incrementMajor :: Version -> Version
- incrementMinor :: Version -> Version
- incrementPatch :: Version -> Version
- isDevelopment :: Version -> Bool
- isPublic :: Version -> Bool
- toString :: Version -> String
- toText :: Version -> Text
- toLazyText :: Version -> Text
- toBuilder :: Version -> Builder
- fromText :: Text -> Either String Version
- fromLazyText :: Text -> Either String Version
- parser :: Parser Version
- data Identifier
- numeric :: Int -> Identifier
- textual :: Text -> Maybe Identifier
- _Numeric :: Applicative f => (Int -> f Int) -> Identifier -> f Identifier
- _Textual :: Applicative f => (Text -> f Text) -> Identifier -> f (Maybe Identifier)
Version
An opaque type representing a successfully decoded or constructed semantic version. See the related functions and lenses for modification and update.
Constructors
:: Int | Major version component. |
-> Int | Minor version component. |
-> Int | Patch version component. |
-> [Identifier] | Release identifiers. |
-> [Identifier] | Metadata identifiers. |
-> Version |
Smart constructor fully specifying all available version components.
A default Version
which can be used to signify initial development.
Note: Equivalent to 0.0.0
Lenses
major :: Functor f => (Int -> f Int) -> Version -> f Version Source
Lens for the major version component.
minor :: Functor f => (Int -> f Int) -> Version -> f Version Source
Lens for minor version component.
patch :: Functor f => (Int -> f Int) -> Version -> f Version Source
Lens for the patch version component.
release :: Functor f => ([Identifier] -> f [Identifier]) -> Version -> f Version Source
Lens for the list of release identifiers.
metadata :: Functor f => ([Identifier] -> f [Identifier]) -> Version -> f Version Source
Lens for the list of metadata identifiers.
Incrementing
The following increment functions are used to ensure that the related version components are reset according to the specification.
See the individual function documentation for specifics regarding each version component.
incrementMajor :: Version -> Version Source
Increment the major component of a Version
by 1, resetting the minor
and patch components.
- Major version X (X.y.z | X > 0) MUST be incremented if any backwards incompatible changes are introduced to the public API.
- It MAY include minor and patch level changes.
- Patch and minor version MUST be reset to 0 when major version is incremented.
incrementMinor :: Version -> Version Source
Increment the minor component of a Version
by 1, resetting the
patch component.
- Minor version Y (x.Y.z | x > 0) MUST be incremented if new, backwards compatible functionality is introduced to the public API.
- It MUST be incremented if any public API functionality is marked as deprecated.
- It MAY be incremented if substantial new functionality or improvements are introduced within the private code.
- It MAY include patch level changes.
- Patch version MUST be reset to 0 when minor version is incremented.
incrementPatch :: Version -> Version Source
Increment the patch component of a Version
by 1.
- Patch version Z (x.y.Z | x > 0) MUST be incremented if only backwards compatible bug fixes are introduced.
- A bug fix is defined as an internal change that fixes incorrect behavior.
Predicates
isDevelopment :: Version -> Bool Source
Check if the Version
is considered unstable.
- Major version zero (0.y.z) is for initial development.
- Anything may change at any time.
- The public API should not be considered stable.
isPublic :: Version -> Bool Source
Check if the Version
is considered stable.
Version 1.0.0 defines the public API. The way in which the version number is incremented after this release is dependent on this public API and how it changes.
Encoding
toLazyText :: Version -> Text Source
Convert a Version
to a Text
representation.
Note: This uses a lower Builder
buffer size optimised for commonly
found version formats. If you have particuarly long version numbers
using toBuilder
and toLazyTextWith
to control the buffer size
is recommended.
Decoding
Identifiers
data Identifier Source
A type representing an individual identifier from the release
or metadata components of a Version
.
- The
Ord
instance implements precedence according to the semantic version specification, with numeric identifiers being of lower precedence than textual identifiers, otherwise lexicographic ordering is used.
The functions numeric
and textual
can be used to construct an Identifier
.
Constructors
numeric :: Int -> Identifier Source
Safely construct a numeric identifier.
textual :: Text -> Maybe Identifier Source
Prisms
_Numeric :: Applicative f => (Int -> f Int) -> Identifier -> f Identifier Source
A prism into the numeric branch of an Identifier
.
_Textual :: Applicative f => (Text -> f Text) -> Identifier -> f (Maybe Identifier) Source
A prism into the textual branch of an Identifier
.