-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Representation, manipulation, and de/serialisation of Semantic Versions.
--
-- Representation, manipulation, and de/serialisation of a Version type
-- following the Semantic Versioning specification.
--
-- For more information see: http://semver.org
@package semver
@version 0.3.0
-- | 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-" toDelimitedBuilder alpha v ".dmz.internal")
--
--
-- Would result in the following Text:
--
--
-- app01-1m2p3d40.dmz.internal
--
--
-- Using the same Delimiters set with delimitedParser
-- would ensure correct decoding behaviour.
module Data.SemVer.Delimited
-- | An opaque set representing the seperators used to delimit semantic
-- version components.
data Delimiters
-- | 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
--
semantic :: Delimiters
-- | Lens for the minor version delimiter. Default: .
minor :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters
-- | Lens for the patch version delimiter. Default: .
patch :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters
-- | Lens for the release component delimiter. Default: -
release :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters
-- | Lens for the metadata component delimiter. Default: +
metadata :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters
-- | Lens for the individual identifier delimiter. Default: .
identifier :: Functor f => (Char -> f Char) -> Delimiters -> f Delimiters
-- | Convert a Version to a Builder using the specified
-- Delimiters set.
toBuilder :: Delimiters -> Version -> Builder
-- | A greedy attoparsec Parser using the specified
-- Delimiters set which requires the entire Text input to
-- match.
parser :: Delimiters -> Parser Version
-- | 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.
module Data.SemVer
-- | An opaque type representing a successfully decoded or constructed
-- semantic version. See the related functions and lenses for
-- modification and update.
--
--
-- - The Eq instance represents exhaustive equality with all
-- components considered.
-- - The Ord instance implements the precedence rules from the
-- semantic version specification with metadata being ignored.
--
data Version
-- | Smart constructor fully specifying all available version components.
version :: Int -> Int -> Int -> [Identifier] -> [Identifier] -> Version
-- | A default Version which can be used to signify initial
-- development.
--
-- Note: Equivalent to 0.0.0
initial :: Version
-- | Lens for the major version component.
major :: Functor f => (Int -> f Int) -> Version -> f Version
-- | Lens for minor version component.
minor :: Functor f => (Int -> f Int) -> Version -> f Version
-- | Lens for the patch version component.
patch :: Functor f => (Int -> f Int) -> Version -> f Version
-- | Lens for the list of release identifiers.
release :: Functor f => ([Identifier] -> f [Identifier]) -> Version -> f Version
-- | Lens for the list of metadata identifiers.
metadata :: Functor f => ([Identifier] -> f [Identifier]) -> Version -> f Version
-- | 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.
--
incrementMajor :: Version -> Version
-- | 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.
--
incrementMinor :: Version -> Version
-- | 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.
--
incrementPatch :: Version -> Version
-- | 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.
--
isDevelopment :: Version -> Bool
-- | 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.
isPublic :: Version -> Bool
-- | Convert a Version to it's readable String
-- representation.
--
-- Note: This is optimised for cases where you require String
-- output, and as such is faster than the semantically equivalent
-- unpack . toLazyText.
toString :: Version -> String
-- | Convert a Version to a strict Text representation.
--
-- Note: Equivalent to toStrict . toLazyText
toText :: Version -> Text
-- | 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.
toLazyText :: Version -> Text
-- | Convert a Version to a Builder.
toBuilder :: Version -> Builder
-- | Parse a Version from Text, returning an attoparsec error
-- message in the Left case on failure.
fromText :: Text -> Either String Version
-- | Parse a Version from Text, returning an attoparsec error
-- message in the Left case on failure.
--
-- Note: The underlying attoparsec Parser is based on Text
-- and this is equivalent to fromText . toStrict
fromLazyText :: Text -> Either String Version
-- | A greedy attoparsec Parser which requires the entire
-- Text input to match.
parser :: Parser Version
-- | 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.
data Identifier
-- | Safely construct a numeric identifier.
numeric :: Int -> Identifier
-- | Construct an identifier from the given Text, returning
-- Nothing if neither a numeric or valid textual input is
-- supplied.
textual :: Text -> Maybe Identifier
-- | A prism into the numeric branch of an Identifier.
_Numeric :: Applicative f => (Int -> f Int) -> Identifier -> f Identifier
-- | A prism into the textual branch of an Identifier.
_Textual :: Applicative f => (Text -> f Text) -> Identifier -> f (Maybe Identifier)