-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Types and parsers for software version numbers.
--   
--   A library for parsing and comparing software version numbers. We like
--   to give version numbers to our software in a myriad of ways. Some ways
--   follow strict guidelines for incrementing and comparison. Some follow
--   conventional wisdom and are generally self-consistent. Some are just
--   plain asinine. This library provides a means of parsing and comparing
--   <i>any</i> style of versioning, be it a nice Semantic Version like
--   this:
--   
--   <pre>
--   1.2.3-r1+git123
--   </pre>
--   
--   ...or a monstrosity like this:
--   
--   <pre>
--   2:10.2+0.0093r3+1-1
--   </pre>
--   
--   Please switch to <a>Semantic Versioning</a> if you aren't currently
--   using it. It provides consistency in version incrementing and has the
--   best constraints on comparisons.
--   
--   This library implements version <tt>2.0.0</tt> of the SemVer spec.
@package versions
@version 6.0.7


-- | A library for parsing and comparing software version numbers.
--   
--   We like to give version numbers to our software in a myriad of
--   different ways. Some ways follow strict guidelines for incrementing
--   and comparison. Some follow conventional wisdom and are generally
--   self-consistent. Some are just plain asinine. This library provides a
--   means of parsing and comparing <i>any</i> style of versioning, be it a
--   nice Semantic Version like this:
--   
--   <pre>
--   1.2.3-r1+git123
--   </pre>
--   
--   ...or a monstrosity like this:
--   
--   <pre>
--   2:10.2+0.0093r3+1-1
--   </pre>
--   
--   Please switch to <a>Semantic Versioning</a> if you aren't currently
--   using it. It provides consistency in version incrementing and has the
--   best constraints on comparisons.
--   
--   <b>This library implements version <tt>2.0.0</tt> of the SemVer
--   spec.</b>
--   
--   <h2>Using the Parsers</h2>
--   
--   In general, <a>versioning</a> is the function you want. It attempts to
--   parse a given <a>Text</a> using the three individual parsers,
--   <a>semver</a>, <a>version</a> and <a>mess</a>. If one fails, it tries
--   the next. If you know you only want to parse one specific version
--   type, use that parser directly (e.g. <a>semver</a>).
module Data.Versions

-- | A top-level Versioning type. Acts as a wrapper for the more specific
--   types. This allows each subtype to have its own parser, and for said
--   parsers to be composed. This is useful for specifying custom behaviour
--   for when a certain parser fails.
data Versioning
Ideal :: !SemVer -> Versioning
General :: !Version -> Versioning
Complex :: !Mess -> Versioning

-- | Short-hand for detecting a <a>SemVer</a>.
isIdeal :: Versioning -> Bool

-- | Short-hand for detecting a <a>Version</a>.
isGeneral :: Versioning -> Bool

-- | Short-hand for detecting a <a>Mess</a>.
isComplex :: Versioning -> Bool

-- | An (Ideal) version number that conforms to Semantic Versioning. This
--   is a <i>prescriptive</i> parser, meaning it follows the SemVer
--   standard.
--   
--   Legal semvers are of the form: MAJOR.MINOR.PATCH-PREREL+META
--   
--   Example: <tt>1.2.3-r1+commithash</tt>
--   
--   Extra Rules:
--   
--   <ol>
--   <li>Pre-release versions have <i>lower</i> precedence than normal
--   versions.</li>
--   <li>Build metadata does not affect version precedence.</li>
--   <li>PREREL and META strings may only contain ASCII alphanumerics and
--   hyphens.</li>
--   </ol>
--   
--   For more information, see <a>http://semver.org</a>
data SemVer
SemVer :: !Word -> !Word -> !Word -> !Maybe Release -> !Maybe Text -> SemVer
[_svMajor] :: SemVer -> !Word
[_svMinor] :: SemVer -> !Word
[_svPatch] :: SemVer -> !Word
[_svPreRel] :: SemVer -> !Maybe Release
[_svMeta] :: SemVer -> !Maybe Text

-- | A PVP version number specific to the Haskell ecosystem. Like SemVer
--   this is a prescriptive scheme, and follows <a>the PVP spec</a>.
--   
--   Legal PVP values are of the form: MAJOR(.MAJOR.MINOR)
--   
--   Example: <tt>1.2.3</tt>
--   
--   Extra Rules:
--   
--   <ol>
--   <li>Each component must be a number.</li>
--   <li>Only the first MAJOR component is actually necessary. Otherwise,
--   there can be any number of components. <tt>1.2.3.4.5.6.7</tt> is
--   legal.</li>
--   <li>Unlike SemVer there are two MAJOR components, and both indicate a
--   breaking change. The spec otherwise designates no special meaning to
--   components past the MINOR position.</li>
--   </ol>
newtype PVP
PVP :: NonEmpty Word -> PVP
[_pComponents] :: PVP -> NonEmpty Word

-- | A version number with decent structure and comparison logic.
--   
--   This is a <i>descriptive</i> scheme, meaning that it encapsulates the
--   most common, unconscious patterns that developers use when assigning
--   version numbers to their software. If not <a>SemVer</a>, most version
--   numbers found in the wild will parse as a <a>Version</a>. These
--   generally conform to the <tt>x.x.x-x</tt> pattern, and may optionally
--   have an <i>epoch</i>.
--   
--   Epochs are prefixes marked by a colon, like in <tt>1:2.3.4</tt>. When
--   comparing two <a>Version</a> values, epochs take precedent. So
--   <tt>2:1.0.0 &gt; 1:9.9.9</tt>. If one of the given <a>Version</a>s has
--   no epoch, its epoch is assumed to be 0.
--   
--   Examples of <tt>Version</tt> that are not <tt>SemVer</tt>: 0.25-2,
--   8.u51-1, 20150826-1, 1:2.3.4
data Version
Version :: !Maybe Word -> !Chunks -> !Maybe Release -> !Maybe Text -> Version
[_vEpoch] :: Version -> !Maybe Word
[_vChunks] :: Version -> !Chunks
[_vRel] :: Version -> !Maybe Release
[_vMeta] :: Version -> !Maybe Text

-- | A (Complex) Mess. This is a <i>descriptive</i> parser, based on
--   examples of stupidly crafted version numbers used in the wild.
--   
--   Groups of letters/numbers, separated by a period, can be further
--   separated by the symbols <tt>_-+:</tt>
--   
--   Some <a>Mess</a> values have a shape that is tantalizingly close to a
--   <a>SemVer</a>. Example: <tt>1.6.0a+2014+m872b87e73dfb-1</tt>. For
--   values like these, we can extract the semver-compatible values out
--   with <a>messMajor</a>, etc.
--   
--   Not guaranteed to have well-defined ordering (<tt>Ord</tt>) behaviour,
--   but so far internal tests show consistency. <a>messMajor</a>, etc.,
--   are used internally where appropriate to enhance accuracy.
data Mess
Mess :: !NonEmpty MChunk -> !Maybe (VSep, Mess) -> Mess

-- | Try to extract the "major" version number from <a>Mess</a>, as if it
--   were a <a>SemVer</a>.
messMajor :: Mess -> Maybe Word

-- | Try to extract the "minor" version number from <a>Mess</a>, as if it
--   were a <a>SemVer</a>.
messMinor :: Mess -> Maybe Word

-- | Try to extract the "patch" version number from <a>Mess</a>, as if it
--   were a <a>SemVer</a>.
messPatch :: Mess -> Maybe Word

-- | Okay, fine, say <a>messPatch</a> couldn't find a nice value. But some
--   <a>Mess</a>es have a "proper" patch-plus-release-candidate value in
--   their patch position, which is parsable as a <a>Chunk</a>.
--   
--   Example: <tt>1.6.0a+2014+m872b87e73dfb-1</tt> We should be able to
--   extract <tt>0a</tt> safely.
messPatchChunk :: Mess -> Maybe Chunk

-- | <a>Chunk</a>s have comparison behaviour according to SemVer's rules
--   for preleases.
newtype Release
Release :: NonEmpty Chunk -> Release

-- | <a>Chunk</a>s that have a comparison behaviour specific to
--   <a>Version</a>.
newtype Chunks
Chunks :: NonEmpty Chunk -> Chunks

-- | A logical unit of a version number.
--   
--   Either entirely numerical (with no leading zeroes) or entirely
--   alphanumerical (with a free mixture of numbers, letters, and hyphens.)
--   
--   Groups of these (like <a>Release</a>) are separated by periods to form
--   a full section of a version number.
--   
--   Examples:
--   
--   <pre>
--   1
--   20150826
--   r3
--   0rc1-abc3
--   </pre>
data Chunk
Numeric :: !Word -> Chunk
Alphanum :: !Text -> Chunk

-- | Possible values of a section of a <a>Mess</a>. A numeric value is
--   extracted if it could be, alongside the original text it came from.
--   This preserves both <a>Ord</a> and pretty-print behaviour for versions
--   like <tt>1.003.0</tt>.
data MChunk

-- | A nice numeric value.
MDigit :: !Word -> !Text -> MChunk

-- | A numeric value preceeded by an <tt>r</tt>, indicating a revision.
MRev :: !Word -> !Text -> MChunk

-- | Anything else.
MPlain :: !Text -> MChunk

-- | Developers use a number of symbols to seperate groups of
--   digits/letters in their version numbers. These are:
--   
--   <ul>
--   <li>A colon (:). Often denotes an "epoch".</li>
--   <li>A hyphen (-).</li>
--   <li>A tilde (~). Example: <tt>12.0.0-3ubuntu1~20.04.5</tt></li>
--   <li>A plus (+). Stop using this outside of metadata if you are.
--   Example: <tt>10.2+0.93+1-1</tt></li>
--   <li>An underscore (_). Stop using this if you are.</li>
--   </ul>
data VSep
VColon :: VSep
VHyphen :: VSep
VPlus :: VSep
VUnder :: VSep
VTilde :: VSep

-- | Parse a <a>Versioning</a> at compile time.
versioningQ :: Text -> Q Exp

-- | Parse a <a>SemVer</a> at compile time.
semverQ :: Text -> Q Exp

-- | Parse a <a>Version</a> at compile time.
versionQ :: Text -> Q Exp

-- | Parse a <a>Mess</a> at compile time.
messQ :: Text -> Q Exp

-- | Parse a <a>PVP</a> at compile time.
pvpQ :: Text -> Q Exp

-- | Convert a <a>SemVer</a> to a <a>Version</a>.
semverToVersion :: SemVer -> Version

-- | Convert a <a>Version</a> to a <a>Mess</a>.
versionToMess :: Version -> Mess

-- | Convert a <a>Version</a> to a <a>PVP</a>. Fails if there is an epoch
--   present, but otherwise ignores the <a>Release</a> and other metadata.
--   Naturally it also fails if any of the version components contain any
--   non-digits.
versionToPvp :: Version -> Maybe PVP

-- | A synonym for the more verbose <tt>megaparsec</tt> error type.
type ParsingError = ParseErrorBundle Text Void

-- | Parse a piece of <a>Text</a> into either an (Ideal) <a>SemVer</a>, a
--   (General) <a>Version</a>, or a (Complex) <a>Mess</a>.
versioning :: Text -> Either ParsingError Versioning

-- | Parse a (Ideal) Semantic Version.
semver :: Text -> Either ParsingError SemVer

-- | Parse a (Haskell) <a>PVP</a>, as defined above.
pvp :: Text -> Either ParsingError PVP

-- | Parse a (General) <a>Version</a>, as defined above.
version :: Text -> Either ParsingError Version

-- | Parse a (Complex) <a>Mess</a>, as defined above.
mess :: Text -> Either ParsingError Mess

-- | Parse a <a>Versioning</a>. Assumes the version number is the last
--   token in the string.
versioning' :: Parsec Void Text Versioning

-- | Internal megaparsec parser of <a>semver</a>.
semver' :: Parsec Void Text SemVer

-- | Internal megaparsec parser of <a>pvp</a>.
pvp' :: Parsec Void Text PVP

-- | Internal megaparsec parser of <a>version</a>.
version' :: Parsec Void Text Version

-- | Internal megaparsec parser of <a>mess</a>.
mess' :: Parsec Void Text Mess

-- | Convert any parsed Versioning type to its textual representation.
prettyV :: Versioning -> Text

-- | Convert a <a>SemVer</a> back to its textual representation.
prettySemVer :: SemVer -> Text

-- | Convert a <a>PVP</a> back to its textual representation.
prettyPVP :: PVP -> Text

-- | Convert a <a>Version</a> back to its textual representation.
prettyVer :: Version -> Text

-- | Convert a <a>Mess</a> back to its textual representation.
prettyMess :: Mess -> Text

-- | Pretty-print a <a>ParseErrorBundle</a>. All <a>ParseError</a>s in the
--   bundle will be pretty-printed in order together with the corresponding
--   offending lines by doing a single pass over the input stream. The
--   rendered <a>String</a> always ends with a newline.
errorBundlePretty :: (VisualStream s, TraversableStream s, ShowErrorComponent e) => ParseErrorBundle s e -> String

-- | Simple Lenses compatible with both lens and microlens.
type Lens' s a = forall f. Functor f => (a -> f a) -> s -> f s

-- | Simple Traversals compatible with both lens and microlens.
type Traversal' s a = forall f. Applicative f => (a -> f a) -> s -> f s

-- | Version types which sanely and safely yield <a>SemVer</a>-like
--   information about themselves. For instances other than <a>SemVer</a>
--   itself however, these optics may <i>not</i> yield anything, depending
--   on the actual value being traversed. Hence, the optics here are all
--   <a>Traversal'</a>s.
--   
--   Consider the <a>Version</a> <tt>1.2.3.4.5</tt>. We can imagine wanting
--   to increment the minor number:
--   
--   <pre>
--   λ "1.2.3.4.5" &amp; minor %~ (+ 1)
--   "1.3.3.4.5"
--   </pre>
--   
--   But of course something like this would fail:
--   
--   <pre>
--   λ "1.e.3.4.5" &amp; minor %~ (+ 1)
--   "1.e.3.4.5"
--   </pre>
--   
--   However!
--   
--   <pre>
--   λ "1.e.3.4.5" &amp; major %~ (+ 1)
--   "2.e.3.4.5"
--   </pre>
class Semantic v

-- | <pre>
--   MAJOR.minor.patch-prerel+meta
--   </pre>
major :: Semantic v => Traversal' v Word

-- | <pre>
--   major.MINOR.patch-prerel+meta
--   </pre>
minor :: Semantic v => Traversal' v Word

-- | <pre>
--   major.minor.PATCH-prerel+meta
--   </pre>
patch :: Semantic v => Traversal' v Word

-- | <pre>
--   major.minor.patch-PREREL+meta
--   </pre>
release :: Semantic v => Traversal' v (Maybe Release)

-- | <pre>
--   major.minor.patch-prerel+META
--   </pre>
meta :: Semantic v => Traversal' v (Maybe Text)

-- | A Natural Transformation into an proper <a>SemVer</a>.
semantic :: Semantic v => Traversal' v SemVer

-- | Traverse some Text for its inner versioning.
--   
--   <pre>
--   λ "1.2.3" &amp; _Versioning . _Ideal . patch %~ (+ 1)  -- or just: "1.2.3" &amp; patch %~ (+ 1)
--   "1.2.4"
--   </pre>
_Versioning :: Traversal' Text Versioning

-- | Traverse some Text for its inner SemVer.
_SemVer :: Traversal' Text SemVer

-- | Traverse some Text for its inner Version.
_Version :: Traversal' Text Version

-- | Traverse some Text for its inner Mess.
_Mess :: Traversal' Text Mess

-- | Possibly extract a <a>SemVer</a> from a <a>Versioning</a>.
_Ideal :: Traversal' Versioning SemVer

-- | Possibly extract a <a>Version</a> from a <a>Versioning</a>.
_General :: Traversal' Versioning Version

-- | Possibly extract a <a>Mess</a> from a <a>Versioning</a>.
_Complex :: Traversal' Versioning Mess

-- | A <a>Version</a>'s inner epoch <a>Word</a>.
epoch :: Lens' Version (Maybe Word)
instance Data.Hashable.Class.Hashable Data.Versions.Chunk
instance Control.DeepSeq.NFData Data.Versions.Chunk
instance Data.Data.Data Data.Versions.Chunk
instance Language.Haskell.TH.Syntax.Lift Data.Versions.Chunk
instance GHC.Generics.Generic Data.Versions.Chunk
instance GHC.Read.Read Data.Versions.Chunk
instance GHC.Show.Show Data.Versions.Chunk
instance GHC.Classes.Eq Data.Versions.Chunk
instance Data.Hashable.Class.Hashable Data.Versions.Release
instance Control.DeepSeq.NFData Data.Versions.Release
instance Data.Data.Data Data.Versions.Release
instance Language.Haskell.TH.Syntax.Lift Data.Versions.Release
instance GHC.Generics.Generic Data.Versions.Release
instance GHC.Read.Read Data.Versions.Release
instance GHC.Show.Show Data.Versions.Release
instance GHC.Classes.Eq Data.Versions.Release
instance Data.Hashable.Class.Hashable Data.Versions.SemVer
instance Control.DeepSeq.NFData Data.Versions.SemVer
instance Data.Data.Data Data.Versions.SemVer
instance Language.Haskell.TH.Syntax.Lift Data.Versions.SemVer
instance GHC.Generics.Generic Data.Versions.SemVer
instance GHC.Show.Show Data.Versions.SemVer
instance Data.Hashable.Class.Hashable Data.Versions.PVP
instance Control.DeepSeq.NFData Data.Versions.PVP
instance Data.Data.Data Data.Versions.PVP
instance Language.Haskell.TH.Syntax.Lift Data.Versions.PVP
instance GHC.Generics.Generic Data.Versions.PVP
instance GHC.Show.Show Data.Versions.PVP
instance GHC.Classes.Ord Data.Versions.PVP
instance GHC.Classes.Eq Data.Versions.PVP
instance Data.Hashable.Class.Hashable Data.Versions.Chunks
instance Control.DeepSeq.NFData Data.Versions.Chunks
instance Data.Data.Data Data.Versions.Chunks
instance Language.Haskell.TH.Syntax.Lift Data.Versions.Chunks
instance GHC.Generics.Generic Data.Versions.Chunks
instance GHC.Show.Show Data.Versions.Chunks
instance GHC.Classes.Eq Data.Versions.Chunks
instance Data.Hashable.Class.Hashable Data.Versions.Version
instance Control.DeepSeq.NFData Data.Versions.Version
instance Data.Data.Data Data.Versions.Version
instance Language.Haskell.TH.Syntax.Lift Data.Versions.Version
instance GHC.Generics.Generic Data.Versions.Version
instance GHC.Show.Show Data.Versions.Version
instance GHC.Classes.Eq Data.Versions.Version
instance Data.Hashable.Class.Hashable Data.Versions.MChunk
instance Control.DeepSeq.NFData Data.Versions.MChunk
instance Data.Data.Data Data.Versions.MChunk
instance Language.Haskell.TH.Syntax.Lift Data.Versions.MChunk
instance GHC.Generics.Generic Data.Versions.MChunk
instance GHC.Show.Show Data.Versions.MChunk
instance GHC.Classes.Eq Data.Versions.MChunk
instance Data.Hashable.Class.Hashable Data.Versions.VSep
instance Control.DeepSeq.NFData Data.Versions.VSep
instance Data.Data.Data Data.Versions.VSep
instance Language.Haskell.TH.Syntax.Lift Data.Versions.VSep
instance GHC.Generics.Generic Data.Versions.VSep
instance GHC.Show.Show Data.Versions.VSep
instance GHC.Classes.Eq Data.Versions.VSep
instance Data.Hashable.Class.Hashable Data.Versions.Mess
instance Control.DeepSeq.NFData Data.Versions.Mess
instance Data.Data.Data Data.Versions.Mess
instance Language.Haskell.TH.Syntax.Lift Data.Versions.Mess
instance GHC.Generics.Generic Data.Versions.Mess
instance GHC.Show.Show Data.Versions.Mess
instance GHC.Classes.Eq Data.Versions.Mess
instance Data.Data.Data Data.Versions.Versioning
instance Language.Haskell.TH.Syntax.Lift Data.Versions.Versioning
instance Data.Hashable.Class.Hashable Data.Versions.Versioning
instance Control.DeepSeq.NFData Data.Versions.Versioning
instance GHC.Generics.Generic Data.Versions.Versioning
instance GHC.Show.Show Data.Versions.Versioning
instance GHC.Classes.Eq Data.Versions.Versioning
instance GHC.Classes.Ord Data.Versions.Release
instance GHC.Classes.Ord Data.Versions.Chunks
instance GHC.Classes.Ord Data.Versions.Versioning
instance Data.Versions.Semantic Data.Versions.Versioning
instance GHC.Classes.Ord Data.Versions.Mess
instance Data.Versions.Semantic Data.Versions.Mess
instance GHC.Classes.Ord Data.Versions.MChunk
instance GHC.Classes.Ord Data.Versions.Version
instance Data.Versions.Semantic Data.Versions.Version
instance Data.Versions.Semantic Data.Versions.PVP
instance Data.Versions.Semantic Data.Text.Internal.Text
instance Data.Versions.Semantic Data.Versions.SemVer
instance GHC.Classes.Eq Data.Versions.SemVer
instance GHC.Classes.Ord Data.Versions.SemVer
