-- 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 -- any style of versioning, be it a nice Semantic Version like -- this: -- --
--   1.2.3-r1+git123
--   
-- -- ...or a monstrosity like this: -- --
--   2:10.2+0.0093r3+1-1
--   
-- -- Please switch to Semantic Versioning if you aren't currently -- using it. It provides consistency in version incrementing and has the -- best constraints on comparisons. @package versions @version 3.1.1 -- | 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 any style of versioning, be it a -- nice Semantic Version like this: -- --
--   1.2.3-r1+git123
--   
-- -- ...or a monstrosity like this: -- --
--   2:10.2+0.0093r3+1-1
--   
-- -- Please switch to Semantic Versioning if you aren't currently -- using it. It provides consistency in version incrementing and has the -- best constraints on comparisons. -- --

Using the Parsers

-- -- In general, parseV is the function you want. It attempts to -- parse a given Text using the three individual parsers, -- semver, version and mess. 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. semver). 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 -- | An (Ideal) version number that conforms to Semantic Versioning. This -- is a prescriptive parser, meaning it follows the SemVer -- standard. -- -- Legal semvers are of the form: MAJOR.MINOR.PATCH-PREREL+META -- -- Example: 1.2.3-r1+commithash -- -- Extra Rules: -- --
    --
  1. Pre-release versions have lower precedence than normal -- versions.
  2. --
  3. Build metadata does not affect version precedence.
  4. --
-- -- For more information, see http://semver.org data SemVer SemVer :: Int -> Int -> Int -> [VChunk] -> [VChunk] -> SemVer [_svMajor] :: SemVer -> Int [_svMinor] :: SemVer -> Int [_svPatch] :: SemVer -> Int [_svPreRel] :: SemVer -> [VChunk] [_svMeta] :: SemVer -> [VChunk] -- | A (General) Version. Not quite as ideal as a SemVer, but has -- some internal consistancy from version to version. Generally conforms -- to the x.x.x-x pattern, and may optionally have an -- epoch. These are prefixes marked by a colon, like in -- 1:2.3.4. -- -- Examples of Version that are not SemVer: 0.25-2, -- 8.u51-1, 20150826-1, 1:2.3.4 data Version Version :: Maybe Int -> [VChunk] -> [VChunk] -> Version [_vEpoch] :: Version -> Maybe Int [_vChunks] :: Version -> [VChunk] [_vRel] :: Version -> [VChunk] -- | A (Complex) Mess. This is a descriptive 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 _-+: -- -- Unfortunately, VChunks cannot be used here, as some -- developers have numbers like 1.003.04 which make parsers -- quite sad. -- -- Not guaranteed to have well-defined ordering (Ord) behaviour, -- but so far internal tests show consistency. data Mess VLeaf :: [Text] -> Mess VNode :: [Text] -> VSep -> Mess -> Mess -- | A single unit of a Version. May be digits or a string of characters. -- Groups of these are called VChunks, and are the identifiers -- separated by periods in the source. data VUnit Digits :: Int -> VUnit Str :: Text -> VUnit -- | A logical unit of a version number. Can consist of multiple letters -- and numbers. type VChunk = [VUnit] -- | Developers use a number of symbols to seperate groups of -- digits/letters in their version numbers. These are: -- -- data VSep VColon :: VSep VHyphen :: VSep VPlus :: VSep VUnder :: VSep -- | A wrapper for a parser function. Can be composed via their Monoid -- instance, such that a different parser can be tried if a previous one -- fails. newtype VParser VParser :: (Text -> Either ParsingError Versioning) -> VParser [runVP] :: VParser -> Text -> Either ParsingError Versioning -- | A synonym for the more verbose megaparsec error type. type ParsingError = ParseError (Token Text) Dec -- | Parse a (Ideal) Semantic Version. semver :: Text -> Either ParsingError SemVer -- | Parse a (General) Version, as defined above. version :: Text -> Either ParsingError Version -- | Parse a (Complex) Mess, as defined above. mess :: Text -> Either ParsingError Mess -- | Parse a piece of Text into either an (Ideal) SemVer, a -- (General) Version, or a (Complex) Mess. parseV :: Text -> Either ParsingError Versioning -- | A wrapped SemVer parser. Can be composed with other parsers. semverP :: VParser -- | A wrapped Version parser. Can be composed with other parsers. versionP :: VParser -- | A wrapped Mess parser. Can be composed with other parsers. messP :: VParser -- | Internal megaparsec parser of semverP. semver' :: Parser SemVer -- | Internal megaparsec parser of versionP. version' :: Parser Version -- | Internal megaparsec parser of messP. mess' :: Parser Mess -- | Convert any parsed Versioning type to its textual representation. prettyV :: Versioning -> Text -- | Convert a SemVer back to its textual representation. prettySemVer :: SemVer -> Text -- | Convert a Version back to its textual representation. prettyVer :: Version -> Text -- | Convert a Mess back to its textual representation. prettyMess :: Mess -> Text -- | Pretty-print ParseError. The rendered String always ends -- with a newline. -- -- The function is defined as: -- --
--   parseErrorPretty e =
--     sourcePosStackPretty (errorPos e) ++ ":\n" ++ parseErrorTextPretty e
--   
parseErrorPretty :: (Ord t, ShowToken t, ShowErrorComponent e) => ParseError t e -> String -- | Traverse some Text for its inner versioning. -- --
--   _Versioning :: Traversal' Text Versioning
--   
-- --
--   ("1.2.3" & _Versioning . _Ideal . svPatch %~ (+ 1)) == "1.2.4"
--   
_Versioning :: Applicative f => (Versioning -> f Versioning) -> Text -> f Text -- | Traverse some Text for its inner SemVer. -- --
--   _SemVer :: Traversal' Text SemVer
--   
_SemVer :: Applicative f => (SemVer -> f SemVer) -> Text -> f Text -- | Traverse some Text for its inner Version. -- --
--   _Version :: Traversal' Text Version
--   
_Version :: Applicative f => (Version -> f Version) -> Text -> f Text -- |
--   _Ideal :: Traversal' Versioning SemVer
--   
_Ideal :: Applicative f => (SemVer -> f SemVer) -> Versioning -> f Versioning -- |
--   _General :: Traversal' Versioning Version
--   
_General :: Applicative f => (Version -> f Version) -> Versioning -> f Versioning -- |
--   _Complex :: Traversal' Versioning Mess
--   
_Complex :: Applicative f => (Mess -> f Mess) -> Versioning -> f Versioning -- |
--   svMajor :: Lens' SemVer Int
--   
svMajor :: Functor f => (Int -> f Int) -> SemVer -> f SemVer -- |
--   svMinor :: Lens' SemVer Int
--   
svMinor :: Functor f => (Int -> f Int) -> SemVer -> f SemVer -- |
--   svPatch :: Lens' SemVer Int
--   
svPatch :: Functor f => (Int -> f Int) -> SemVer -> f SemVer -- |
--   svPreRel :: Lens' SemVer Int
--   
svPreRel :: Functor f => ([VChunk] -> f [VChunk]) -> SemVer -> f SemVer -- |
--   svMeta :: Lens' SemVer Int
--   
svMeta :: Functor f => ([VChunk] -> f [VChunk]) -> SemVer -> f SemVer -- |
--   vEpoch :: Lens' Version (Maybe Int)
--   
vEpoch :: Functor f => (Maybe Int -> f (Maybe Int)) -> Version -> f Version -- |
--   vChunks :: Lens' Version [VChunk]
--   
vChunks :: Functor f => ([VChunk] -> f [VChunk]) -> Version -> f Version -- |
--   vRel :: Lens' Version [VChunk]
--   
vRel :: Functor f => ([VChunk] -> f [VChunk]) -> Version -> f Version -- |
--   _Digits :: Traversal' VUnit Int
--   
_Digits :: Applicative f => (Int -> f Int) -> VUnit -> f VUnit -- |
--   _Str :: Traversal' VUnit Text
--   
_Str :: Applicative f => (Text -> f Text) -> VUnit -> f VUnit 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 Data.Hashable.Class.Hashable Data.Versions.Mess instance Control.DeepSeq.NFData 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.Hashable.Class.Hashable Data.Versions.VSep instance Control.DeepSeq.NFData 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.Version instance Control.DeepSeq.NFData 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.SemVer instance Control.DeepSeq.NFData Data.Versions.SemVer instance GHC.Generics.Generic Data.Versions.SemVer instance GHC.Show.Show Data.Versions.SemVer instance Data.Hashable.Class.Hashable Data.Versions.VUnit instance Control.DeepSeq.NFData Data.Versions.VUnit instance GHC.Generics.Generic Data.Versions.VUnit instance GHC.Classes.Ord Data.Versions.VUnit instance GHC.Read.Read Data.Versions.VUnit instance GHC.Show.Show Data.Versions.VUnit instance GHC.Classes.Eq Data.Versions.VUnit instance GHC.Classes.Ord Data.Versions.Versioning instance GHC.Classes.Eq Data.Versions.SemVer instance GHC.Classes.Ord Data.Versions.SemVer instance GHC.Base.Monoid Data.Versions.SemVer instance GHC.Classes.Ord Data.Versions.Version instance GHC.Classes.Ord Data.Versions.Mess instance GHC.Base.Monoid Data.Versions.VParser