versions-6.0.7: Types and parsers for software version numbers.

Copyright | (c) Colin Woodbury 2015 - 2023
License | BSD3
Maintainer | Colin Woodbury <colin@fosskers.ca>
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Versions

Contents

- Types
  - Compile-time Constructors
  - Conversions
- Parsing Versions
  - Megaparsec Parsers
- Pretty Printing
- Lenses
  - Traversing Text
  - Versioning Traversals
  - (General) Version Lenses

Description

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.

This library implements version `2.0.0` of the SemVer spec.

## Using the Parsers

In general, `versioning` 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`).

Synopsis

- data Versioning
  - = Ideal !SemVer
  - | General !Version
  - | Complex !Mess
- isIdeal :: Versioning -> Bool
- isGeneral :: Versioning -> Bool
- isComplex :: Versioning -> Bool
- data SemVer = SemVer {
  - _svMajor :: !Word
  - _svMinor :: !Word
  - _svPatch :: !Word
  - _svPreRel :: !(Maybe Release)
  - _svMeta :: !(Maybe Text)
  }
- newtype PVP = PVP {
  - _pComponents :: NonEmpty Word
  }
- data Version = Version {
  - _vEpoch :: !(Maybe Word)
  - _vChunks :: !Chunks
  - _vRel :: !(Maybe Release)
  - _vMeta :: !(Maybe Text)
  }
- data Mess = Mess !(NonEmpty MChunk) !(Maybe (VSep, Mess))
- messMajor :: Mess -> Maybe Word
- messMinor :: Mess -> Maybe Word
- messPatch :: Mess -> Maybe Word
- messPatchChunk :: Mess -> Maybe Chunk
- newtype Release = Release (NonEmpty Chunk)
- newtype Chunks = Chunks (NonEmpty Chunk)
- data Chunk
  - = Numeric !Word
  - | Alphanum !Text
- data MChunk
  - = MDigit !Word !Text
  - | MRev !Word !Text
  - | MPlain !Text
- data VSep
  - = VColon
  - | VHyphen
  - | VPlus
  - | VUnder
  - | VTilde
- versioningQ :: Text -> Q Exp
- semverQ :: Text -> Q Exp
- versionQ :: Text -> Q Exp
- messQ :: Text -> Q Exp
- pvpQ :: Text -> Q Exp
- semverToVersion :: SemVer -> Version
- versionToMess :: Version -> Mess
- versionToPvp :: Version -> Maybe PVP
- type ParsingError = ParseErrorBundle Text Void
- versioning :: Text -> Either ParsingError Versioning
- semver :: Text -> Either ParsingError SemVer
- pvp :: Text -> Either ParsingError PVP
- version :: Text -> Either ParsingError Version
- mess :: Text -> Either ParsingError Mess
- versioning' :: Parsec Void Text Versioning
- semver' :: Parsec Void Text SemVer
- pvp' :: Parsec Void Text PVP
- version' :: Parsec Void Text Version
- mess' :: Parsec Void Text Mess
- prettyV :: Versioning -> Text
- prettySemVer :: SemVer -> Text
- prettyPVP :: PVP -> Text
- prettyVer :: Version -> Text
- prettyMess :: Mess -> Text
- errorBundlePretty :: (VisualStream s, TraversableStream s, ShowErrorComponent e) => ParseErrorBundle s e -> String
- type Lens' s a = forall f. Functor f => (a -> f a) -> s -> f s
- type Traversal' s a = forall f. Applicative f => (a -> f a) -> s -> f s
- class Semantic v where
  - major :: Traversal' v Word
  - minor :: Traversal' v Word
  - patch :: Traversal' v Word
  - release :: Traversal' v (Maybe Release)
  - meta :: Traversal' v (Maybe Text)
  - semantic :: Traversal' v SemVer
- _Versioning :: Traversal' Text Versioning
- _SemVer :: Traversal' Text SemVer
- _Version :: Traversal' Text Version
- _Mess :: Traversal' Text Mess
- _Ideal :: Traversal' Versioning SemVer
- _General :: Traversal' Versioning Version
- _Complex :: Traversal' Versioning Mess
- epoch :: Lens' Version (Maybe Word)

# Types

data Versioning Source #

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.

Constructors

Ideal !SemVer |
General !Version |
Complex !Mess |

#### Instances

Instances details

Data Versioning Source # |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Versioning -> c Versioning Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Versioning Source #

toConstr :: Versioning -> Constr Source #

dataTypeOf :: Versioning -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Versioning) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Versioning) Source #

gmapT :: (forall b. Data b => b -> b) -> Versioning -> Versioning Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Versioning -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Versioning -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Versioning -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Versioning -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Versioning -> m Versioning Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Versioning -> m Versioning Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Versioning -> m Versioning Source #

Generic Versioning Source # |
Instance details Defined in Data.Versions Associated Types type Rep Versioning :: Type -> Type Source # Methods from :: Versioning -> Rep Versioning x Source # to :: Rep Versioning x -> Versioning Source #
Show Versioning Source # |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> Versioning -> ShowS Source # show :: Versioning -> String Source # showList :: [Versioning] -> ShowS Source #
NFData Versioning Source # |
Instance details Defined in Data.Versions Methods rnf :: Versioning -> () Source #
Eq Versioning Source # |
Instance details Defined in Data.Versions Methods (==) :: Versioning -> Versioning -> Bool Source # (/=) :: Versioning -> Versioning -> Bool Source #

Ord Versioning Source #

Comparison of `Ideal`s is always well defined.

If comparison of `General`s is well-defined, then comparison of `Ideal` and `General` is well-defined, as there exists a perfect mapping from `Ideal` to `General`.

If comparison of `Complex`es is well-defined, then comparison of `General` and `Complex` is well defined for the same reason. This implies comparison of `Ideal` and `Complex` is also well-defined.

Instance details

Defined in Data.Versions

Methods

compare :: Versioning -> Versioning -> Ordering Source #

(<) :: Versioning -> Versioning -> Bool Source #

(<=) :: Versioning -> Versioning -> Bool Source #

(>) :: Versioning -> Versioning -> Bool Source #

(>=) :: Versioning -> Versioning -> Bool Source #

max :: Versioning -> Versioning -> Versioning Source #

min :: Versioning -> Versioning -> Versioning Source #

Hashable Versioning Source # |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> Versioning -> Int Source # hash :: Versioning -> Int Source #
Semantic Versioning Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' Versioning Word Source # minor :: Traversal' Versioning Word Source # patch :: Traversal' Versioning Word Source # release :: Traversal' Versioning (Maybe Release) Source # meta :: Traversal' Versioning (Maybe Text) Source # semantic :: Traversal' Versioning SemVer Source #
Lift Versioning Source # |
Instance details Defined in Data.Versions Methods lift :: Quote m => Versioning -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Versioning -> Code m Versioning Source #
type Rep Versioning Source # |

Instance details

Defined in Data.Versions

type Rep Versioning = D1 ('MetaData "Versioning" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'False) (C1 ('MetaCons "Ideal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SemVer)) :+: (C1 ('MetaCons "General" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Version)) :+: C1 ('MetaCons "Complex" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Mess))))

isIdeal :: Versioning -> Bool Source #

Short-hand for detecting a `SemVer`.

isGeneral :: Versioning -> Bool Source #

Short-hand for detecting a `Version`.

isComplex :: Versioning -> Bool Source #

Short-hand for detecting a `Mess`.

data SemVer Source #

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. Build metadata does not affect version precedence.
3. PREREL and META strings may only contain ASCII alphanumerics and hyphens.

For more information, see http://semver.org

Constructors

SemVer |

Fields

- _svMajor :: !Word
- _svMinor :: !Word
- _svPatch :: !Word
- _svPreRel :: !(Maybe Release)
- _svMeta :: !(Maybe Text)

#### Instances

Instances details

Data SemVer Source # |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SemVer -> c SemVer Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SemVer Source #

toConstr :: SemVer -> Constr Source #

dataTypeOf :: SemVer -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SemVer) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SemVer) Source #

gmapT :: (forall b. Data b => b -> b) -> SemVer -> SemVer Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SemVer -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SemVer -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> SemVer -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SemVer -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SemVer -> m SemVer Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SemVer -> m SemVer Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SemVer -> m SemVer Source #

Generic SemVer Source # |
Instance details Defined in Data.Versions Associated Types type Rep SemVer :: Type -> Type Source # Methods from :: SemVer -> Rep SemVer x Source # to :: Rep SemVer x -> SemVer Source #
Show SemVer Source # |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> SemVer -> ShowS Source # show :: SemVer -> String Source # showList :: [SemVer] -> ShowS Source #
NFData SemVer Source # |
Instance details Defined in Data.Versions Methods rnf :: SemVer -> () Source #
Eq SemVer Source # | Two SemVers are equal if all fields except metadata are equal.
Instance details Defined in Data.Versions Methods (==) :: SemVer -> SemVer -> Bool Source # (/=) :: SemVer -> SemVer -> Bool Source #
Ord SemVer Source # | Build metadata does not affect version precedence.
Instance details Defined in Data.Versions Methods compare :: SemVer -> SemVer -> Ordering Source # (<) :: SemVer -> SemVer -> Bool Source # (<=) :: SemVer -> SemVer -> Bool Source # (>) :: SemVer -> SemVer -> Bool Source # (>=) :: SemVer -> SemVer -> Bool Source # max :: SemVer -> SemVer -> SemVer Source # min :: SemVer -> SemVer -> SemVer Source #
Hashable SemVer Source # |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> SemVer -> Int Source # hash :: SemVer -> Int Source #
Semantic SemVer Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' SemVer Word Source # minor :: Traversal' SemVer Word Source # patch :: Traversal' SemVer Word Source # release :: Traversal' SemVer (Maybe Release) Source # meta :: Traversal' SemVer (Maybe Text) Source # semantic :: Traversal' SemVer SemVer Source #
Lift SemVer Source # |
Instance details Defined in Data.Versions Methods lift :: Quote m => SemVer -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => SemVer -> Code m SemVer Source #
type Rep SemVer Source # |

Instance details

Defined in Data.Versions

type Rep SemVer = D1 ('MetaData "SemVer" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'False) (C1 ('MetaCons "SemVer" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_svMajor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word) :*: S1 ('MetaSel ('Just "_svMinor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word)) :*: (S1 ('MetaSel ('Just "_svPatch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word) :*: (S1 ('MetaSel ('Just "_svPreRel") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Release)) :*: S1 ('MetaSel ('Just "_svMeta") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Text))))))

newtype PVP Source #

A PVP version number specific to the Haskell ecosystem. Like SemVer this is a prescriptive scheme, and follows the PVP spec.

Legal PVP values are of the form: MAJOR(.MAJOR.MINOR)

Example: `1.2.3`

Extra Rules:

1. Each component must be a number.
2. Only the first MAJOR component is actually necessary. Otherwise, there can be any number of components. `1.2.3.4.5.6.7` is legal.
3. 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.

Constructors

PVP |

Fields

- _pComponents :: NonEmpty Word

#### Instances

Instances details

Data PVP Source # |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PVP -> c PVP Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PVP Source #

toConstr :: PVP -> Constr Source #

dataTypeOf :: PVP -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PVP) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PVP) Source #

gmapT :: (forall b. Data b => b -> b) -> PVP -> PVP Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PVP -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PVP -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> PVP -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> PVP -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> PVP -> m PVP Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PVP -> m PVP Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PVP -> m PVP Source #

Generic PVP Source # |
Instance details Defined in Data.Versions Associated Types type Rep PVP :: Type -> Type Source # Methods from :: PVP -> Rep PVP x Source # to :: Rep PVP x -> PVP Source #
Show PVP Source # |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> PVP -> ShowS Source # show :: PVP -> String Source # showList :: [PVP] -> ShowS Source #
NFData PVP Source # |
Instance details Defined in Data.Versions Methods rnf :: PVP -> () Source #
Eq PVP Source # |
Instance details Defined in Data.Versions Methods (==) :: PVP -> PVP -> Bool Source # (/=) :: PVP -> PVP -> Bool Source #
Ord PVP Source # |
Instance details Defined in Data.Versions Methods compare :: PVP -> PVP -> Ordering Source # (<) :: PVP -> PVP -> Bool Source # (<=) :: PVP -> PVP -> Bool Source # (>) :: PVP -> PVP -> Bool Source # (>=) :: PVP -> PVP -> Bool Source # max :: PVP -> PVP -> PVP Source # min :: PVP -> PVP -> PVP Source #
Hashable PVP Source # |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> PVP -> Int Source # hash :: PVP -> Int Source #
Semantic PVP Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' PVP Word Source # minor :: Traversal' PVP Word Source # patch :: Traversal' PVP Word Source # release :: Traversal' PVP (Maybe Release) Source # meta :: Traversal' PVP (Maybe Text) Source # semantic :: Traversal' PVP SemVer Source #
Lift PVP Source # |
Instance details Defined in Data.Versions Methods lift :: Quote m => PVP -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => PVP -> Code m PVP Source #
type Rep PVP Source # |
Instance details Defined in Data.Versions type Rep PVP = D1 ('MetaData "PVP" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'True) (C1 ('MetaCons "PVP" 'PrefixI 'True) (S1 ('MetaSel ('Just "_pComponents") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty Word))))

data Version Source #

A version number with decent structure and comparison logic.

This is a descriptive scheme, meaning that it encapsulates the most common, unconscious patterns that developers use when assigning version numbers to their software. If not `SemVer`, most version numbers found in the wild will parse as a `Version`. These generally conform to the `x.x.x-x` pattern, and may optionally have an epoch.

Epochs are prefixes marked by a colon, like in `1:2.3.4`. When comparing two `Version` values, epochs take precedent. So `2:1.0.0 > 1:9.9.9`. If one of the given `Version`s has no epoch, its epoch is assumed to be 0.

Examples of `Version` that are not `SemVer`: 0.25-2, 8.u51-1, 20150826-1, 1:2.3.4

Constructors

Version |

Fields

- _vEpoch :: !(Maybe Word)
- _vChunks :: !Chunks
- _vRel :: !(Maybe Release)
- _vMeta :: !(Maybe Text)

#### Instances

Instances details

Data Version Source # |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Version -> c Version Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Version Source #

toConstr :: Version -> Constr Source #

dataTypeOf :: Version -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Version) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Version) Source #

gmapT :: (forall b. Data b => b -> b) -> Version -> Version Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Version -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Version -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Version -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Version -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Version -> m Version Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Version -> m Version Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Version -> m Version Source #

Generic Version Source # |
Instance details Defined in Data.Versions Associated Types type Rep Version :: Type -> Type Source # Methods from :: Version -> Rep Version x Source # to :: Rep Version x -> Version Source #
Show Version Source # |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> Version -> ShowS Source # show :: Version -> String Source # showList :: [Version] -> ShowS Source #
NFData Version Source # |
Instance details Defined in Data.Versions Methods rnf :: Version -> () Source #
Eq Version Source # |
Instance details Defined in Data.Versions Methods (==) :: Version -> Version -> Bool Source # (/=) :: Version -> Version -> Bool Source #
Ord Version Source # | Customized. As in SemVer, metadata is ignored for the purpose of comparison.
Instance details Defined in Data.Versions Methods compare :: Version -> Version -> Ordering Source # (<) :: Version -> Version -> Bool Source # (<=) :: Version -> Version -> Bool Source # (>) :: Version -> Version -> Bool Source # (>=) :: Version -> Version -> Bool Source # max :: Version -> Version -> Version Source # min :: Version -> Version -> Version Source #
Hashable Version Source # |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> Version -> Int Source # hash :: Version -> Int Source #
Semantic Version Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' Version Word Source # minor :: Traversal' Version Word Source # patch :: Traversal' Version Word Source # release :: Traversal' Version (Maybe Release) Source # meta :: Traversal' Version (Maybe Text) Source # semantic :: Traversal' Version SemVer Source #
Lift Version Source # |
Instance details Defined in Data.Versions Methods lift :: Quote m => Version -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Version -> Code m Version Source #
type Rep Version Source # |

Instance details

Defined in Data.Versions

type Rep Version = D1 ('MetaData "Version" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'False) (C1 ('MetaCons "Version" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_vEpoch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Word)) :*: S1 ('MetaSel ('Just "_vChunks") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Chunks)) :*: (S1 ('MetaSel ('Just "_vRel") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Release)) :*: S1 ('MetaSel ('Just "_vMeta") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Text)))))

data Mess Source #

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 `_-+:`

Some `Mess` values have a shape that is tantalizingly close to a `SemVer`. Example: `1.6.0a+2014+m872b87e73dfb-1`. For values like these, we can extract the semver-compatible values out with `messMajor`, etc.

Not guaranteed to have well-defined ordering (`Ord`) behaviour, but so far internal tests show consistency. `messMajor`, etc., are used internally where appropriate to enhance accuracy.

Constructors

Mess !(NonEmpty MChunk) !(Maybe (VSep, Mess)) |

#### Instances

Instances details

Data Mess Source # |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Mess -> c Mess Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Mess Source #

toConstr :: Mess -> Constr Source #

dataTypeOf :: Mess -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Mess) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Mess) Source #

gmapT :: (forall b. Data b => b -> b) -> Mess -> Mess Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Mess -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Mess -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Mess -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Mess -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Mess -> m Mess Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Mess -> m Mess Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Mess -> m Mess Source #

Generic Mess Source # |
Instance details Defined in Data.Versions Associated Types type Rep Mess :: Type -> Type Source # Methods from :: Mess -> Rep Mess x Source # to :: Rep Mess x -> Mess Source #
Show Mess Source # |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> Mess -> ShowS Source # show :: Mess -> String Source # showList :: [Mess] -> ShowS Source #
NFData Mess Source # |
Instance details Defined in Data.Versions Methods rnf :: Mess -> () Source #
Eq Mess Source # |
Instance details Defined in Data.Versions Methods (==) :: Mess -> Mess -> Bool Source # (/=) :: Mess -> Mess -> Bool Source #
Ord Mess Source # |
Instance details Defined in Data.Versions Methods compare :: Mess -> Mess -> Ordering Source # (<) :: Mess -> Mess -> Bool Source # (<=) :: Mess -> Mess -> Bool Source # (>) :: Mess -> Mess -> Bool Source # (>=) :: Mess -> Mess -> Bool Source # max :: Mess -> Mess -> Mess Source # min :: Mess -> Mess -> Mess Source #
Hashable Mess Source # |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> Mess -> Int Source # hash :: Mess -> Int Source #
Semantic Mess Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' Mess Word Source # minor :: Traversal' Mess Word Source # patch :: Traversal' Mess Word Source # release :: Traversal' Mess (Maybe Release) Source # meta :: Traversal' Mess (Maybe Text) Source # semantic :: Traversal' Mess SemVer Source #
Lift Mess Source # |
Instance details Defined in Data.Versions Methods lift :: Quote m => Mess -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Mess -> Code m Mess Source #
type Rep Mess Source # |

Instance details

Defined in Data.Versions

type Rep Mess = D1 ('MetaData "Mess" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'False) (C1 ('MetaCons "Mess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NonEmpty MChunk)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe (VSep, Mess)))))

messMajor :: Mess -> Maybe Word Source #

Try to extract the "major" version number from `Mess`, as if it were a `SemVer`.

messMinor :: Mess -> Maybe Word Source #

Try to extract the "minor" version number from `Mess`, as if it were a `SemVer`.

messPatch :: Mess -> Maybe Word Source #

Try to extract the "patch" version number from `Mess`, as if it were a `SemVer`.

messPatchChunk :: Mess -> Maybe Chunk Source #

Okay, fine, say `messPatch` couldn't find a nice value. But some `Mess`es have a "proper" patch-plus-release-candidate value in their patch position, which is parsable as a `Chunk`.

Example: `1.6.0a+2014+m872b87e73dfb-1` We should be able to extract `0a` safely.

newtype Release Source #

`Chunk`s have comparison behaviour according to SemVer's rules for preleases.

Constructors

Release (NonEmpty Chunk) |

#### Instances

Instances details

Data Release Source # |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Release -> c Release Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Release Source #

toConstr :: Release -> Constr Source #

dataTypeOf :: Release -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Release) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Release) Source #

gmapT :: (forall b. Data b => b -> b) -> Release -> Release Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Release -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Release -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Release -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Release -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Release -> m Release Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Release -> m Release Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Release -> m Release Source #

Generic Release Source # |
Instance details Defined in Data.Versions Associated Types type Rep Release :: Type -> Type Source # Methods from :: Release -> Rep Release x Source # to :: Rep Release x -> Release Source #
Read Release Source # |
Instance details Defined in Data.Versions Methods readsPrec :: Int -> ReadS Release Source # readList :: ReadS [Release] Source # readPrec :: ReadPrec Release Source # readListPrec :: ReadPrec [Release] Source #
Show Release Source # |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> Release -> ShowS Source # show :: Release -> String Source # showList :: [Release] -> ShowS Source #
NFData Release Source # |
Instance details Defined in Data.Versions Methods rnf :: Release -> () Source #
Eq Release Source # |
Instance details Defined in Data.Versions Methods (==) :: Release -> Release -> Bool Source # (/=) :: Release -> Release -> Bool Source #
Ord Release Source # |
Instance details Defined in Data.Versions Methods compare :: Release -> Release -> Ordering Source # (<) :: Release -> Release -> Bool Source # (<=) :: Release -> Release -> Bool Source # (>) :: Release -> Release -> Bool Source # (>=) :: Release -> Release -> Bool Source # max :: Release -> Release -> Release Source # min :: Release -> Release -> Release Source #
Hashable Release Source # |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> Release -> Int Source # hash :: Release -> Int Source #
Lift Release Source # |
Instance details Defined in Data.Versions Methods lift :: Quote m => Release -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Release -> Code m Release Source #
type Rep Release Source # |
Instance details Defined in Data.Versions type Rep Release = D1 ('MetaData "Release" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'True) (C1 ('MetaCons "Release" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty Chunk))))

newtype Chunks Source #

`Chunk`s that have a comparison behaviour specific to `Version`.

Constructors

Chunks (NonEmpty Chunk) |

#### Instances

Instances details

Data Chunks Source # |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Chunks -> c Chunks Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Chunks Source #

toConstr :: Chunks -> Constr Source #

dataTypeOf :: Chunks -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Chunks) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Chunks) Source #

gmapT :: (forall b. Data b => b -> b) -> Chunks -> Chunks Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Chunks -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Chunks -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Chunks -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Chunks -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Chunks -> m Chunks Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Chunks -> m Chunks Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Chunks -> m Chunks Source #

Generic Chunks Source # |
Instance details Defined in Data.Versions Associated Types type Rep Chunks :: Type -> Type Source # Methods from :: Chunks -> Rep Chunks x Source # to :: Rep Chunks x -> Chunks Source #
Show Chunks Source # |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> Chunks -> ShowS Source # show :: Chunks -> String Source # showList :: [Chunks] -> ShowS Source #
NFData Chunks Source # |
Instance details Defined in Data.Versions Methods rnf :: Chunks -> () Source #
Eq Chunks Source # |
Instance details Defined in Data.Versions Methods (==) :: Chunks -> Chunks -> Bool Source # (/=) :: Chunks -> Chunks -> Bool Source #
Ord Chunks Source # |
Instance details Defined in Data.Versions Methods compare :: Chunks -> Chunks -> Ordering Source # (<) :: Chunks -> Chunks -> Bool Source # (<=) :: Chunks -> Chunks -> Bool Source # (>) :: Chunks -> Chunks -> Bool Source # (>=) :: Chunks -> Chunks -> Bool Source # max :: Chunks -> Chunks -> Chunks Source # min :: Chunks -> Chunks -> Chunks Source #
Hashable Chunks Source # |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> Chunks -> Int Source # hash :: Chunks -> Int Source #
Lift Chunks Source # |
Instance details Defined in Data.Versions Methods lift :: Quote m => Chunks -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Chunks -> Code m Chunks Source #
type Rep Chunks Source # |
Instance details Defined in Data.Versions type Rep Chunks = D1 ('MetaData "Chunks" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'True) (C1 ('MetaCons "Chunks" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty Chunk))))

data Chunk Source #

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 `Release`) are separated by periods to form a full section of a version number.

Examples:

    1
    20150826
    r3
    0rc1-abc3

Constructors

Numeric !Word |
Alphanum !Text |

#### Instances

Instances details

Data Chunk Source # |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Chunk -> c Chunk Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Chunk Source #

toConstr :: Chunk -> Constr Source #

dataTypeOf :: Chunk -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Chunk) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Chunk) Source #

gmapT :: (forall b. Data b => b -> b) -> Chunk -> Chunk Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Chunk -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Chunk -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Chunk -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Chunk -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Chunk -> m Chunk Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Chunk -> m Chunk Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Chunk -> m Chunk Source #

Generic Chunk Source # |
Instance details Defined in Data.Versions Associated Types type Rep Chunk :: Type -> Type Source # Methods from :: Chunk -> Rep Chunk x Source # to :: Rep Chunk x -> Chunk Source #
Read Chunk Source # |
Instance details Defined in Data.Versions Methods readsPrec :: Int -> ReadS Chunk Source # readList :: ReadS [Chunk] Source # readPrec :: ReadPrec Chunk Source # readListPrec :: ReadPrec [Chunk] Source #
Show Chunk Source # |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> Chunk -> ShowS Source # show :: Chunk -> String Source # showList :: [Chunk] -> ShowS Source #
NFData Chunk Source # |
Instance details Defined in Data.Versions Methods rnf :: Chunk -> () Source #
Eq Chunk Source # |
Instance details Defined in Data.Versions Methods (==) :: Chunk -> Chunk -> Bool Source # (/=) :: Chunk -> Chunk -> Bool Source #
Hashable Chunk Source # |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> Chunk -> Int Source # hash :: Chunk -> Int Source #
Lift Chunk Source # |
Instance details Defined in Data.Versions Methods lift :: Quote m => Chunk -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Chunk -> Code m Chunk Source #
type Rep Chunk Source # |

Instance details

Defined in Data.Versions

type Rep Chunk = D1 ('MetaData "Chunk" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'False) (C1 ('MetaCons "Numeric" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word)) :+: C1 ('MetaCons "Alphanum" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))

data MChunk Source #

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

Constructors

MDigit !Word !Text | A nice numeric value.
MRev !Word !Text | A numeric value preceeded by an `r`, indicating a revision.
MPlain !Text | Anything else.

#### Instances

Instances details

Data MChunk Source # |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MChunk -> c MChunk Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MChunk Source #

toConstr :: MChunk -> Constr Source #

dataTypeOf :: MChunk -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c MChunk) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MChunk) Source #

gmapT :: (forall b. Data b => b -> b) -> MChunk -> MChunk Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MChunk -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MChunk -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> MChunk -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> MChunk -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> MChunk -> m MChunk Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MChunk -> m MChunk Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MChunk -> m MChunk Source #

Generic MChunk Source # |
Instance details Defined in Data.Versions Associated Types type Rep MChunk :: Type -> Type Source # Methods from :: MChunk -> Rep MChunk x Source # to :: Rep MChunk x -> MChunk Source #
Show MChunk Source # |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> MChunk -> ShowS Source # show :: MChunk -> String Source # showList :: [MChunk] -> ShowS Source #
NFData MChunk Source # |
Instance details Defined in Data.Versions Methods rnf :: MChunk -> () Source #
Eq MChunk Source # |
Instance details Defined in Data.Versions Methods (==) :: MChunk -> MChunk -> Bool Source # (/=) :: MChunk -> MChunk -> Bool Source #
Ord MChunk Source # |
Instance details Defined in Data.Versions Methods compare :: MChunk -> MChunk -> Ordering Source # (<) :: MChunk -> MChunk -> Bool Source # (<=) :: MChunk -> MChunk -> Bool Source # (>) :: MChunk -> MChunk -> Bool Source # (>=) :: MChunk -> MChunk -> Bool Source # max :: MChunk -> MChunk -> MChunk Source # min :: MChunk -> MChunk -> MChunk Source #
Hashable MChunk Source # |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> MChunk -> Int Source # hash :: MChunk -> Int Source #
Lift MChunk Source # |
Instance details Defined in Data.Versions Methods lift :: Quote m => MChunk -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => MChunk -> Code m MChunk Source #
type Rep MChunk Source # |

Instance details

Defined in Data.Versions

type Rep MChunk = D1 ('MetaData "MChunk" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'False) (C1 ('MetaCons "MDigit" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)) :+: (C1 ('MetaCons "MRev" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)) :+: C1 ('MetaCons "MPlain" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text))))

data VSep Source #

Developers use a number of symbols to seperate groups of digits/letters in their version numbers. These are:

- A colon (:). Often denotes an "epoch".
- A hyphen (-).
- A tilde (~). Example: `12.0.0-3ubuntu1~20.04.5`
- A plus (+). Stop using this outside of metadata if you are. Example: `10.2+0.93+1-1`
- An underscore (_). Stop using this if you are.

Constructors

VColon |
VHyphen |
VPlus |
VUnder |
VTilde |

#### Instances

Instances details

Data VSep Source # |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> VSep -> c VSep Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c VSep Source #

toConstr :: VSep -> Constr Source #

dataTypeOf :: VSep -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c VSep) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c VSep) Source #

gmapT :: (forall b. Data b => b -> b) -> VSep -> VSep Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> VSep -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> VSep -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> VSep -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> VSep -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> VSep -> m VSep Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> VSep -> m VSep Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> VSep -> m VSep Source #

Generic VSep Source # |
Instance details Defined in Data.Versions Associated Types type Rep VSep :: Type -> Type Source # Methods from :: VSep -> Rep VSep x Source # to :: Rep VSep x -> VSep Source #
Show VSep Source # |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> VSep -> ShowS Source # show :: VSep -> String Source # showList :: [VSep] -> ShowS Source #
NFData VSep Source # |
Instance details Defined in Data.Versions Methods rnf :: VSep -> () Source #
Eq VSep Source # |
Instance details Defined in Data.Versions Methods (==) :: VSep -> VSep -> Bool Source # (/=) :: VSep -> VSep -> Bool Source #
Hashable VSep Source # |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> VSep -> Int Source # hash :: VSep -> Int Source #
Lift VSep Source # |
Instance details Defined in Data.Versions Methods lift :: Quote m => VSep -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => VSep -> Code m VSep Source #
type Rep VSep Source # |

Instance details

Defined in Data.Versions

type Rep VSep = D1 ('MetaData "VSep" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'False) ((C1 ('MetaCons "VColon" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "VHyphen" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "VPlus" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "VUnder" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "VTilde" 'PrefixI 'False) (U1 :: Type -> Type))))

## Compile-time Constructors

versioningQ :: Text -> Q Exp Source #

Parse a `Versioning` at compile time.

semverQ :: Text -> Q Exp Source #

Parse a `SemVer` at compile time.

versionQ :: Text -> Q Exp Source #

Parse a `Version` at compile time.

messQ :: Text -> Q Exp Source #

Parse a `Mess` at compile time.

pvpQ :: Text -> Q Exp Source #

Parse a `PVP` at compile time.

## Conversions

semverToVersion :: SemVer -> Version Source #

Convert a `SemVer` to a `Version`.

versionToMess :: Version -> Mess Source #

Convert a `Version` to a `Mess`.

versionToPvp :: Version -> Maybe PVP Source #

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

# Parsing Versions

type ParsingError = ParseErrorBundle Text Void Source #

A synonym for the more verbose `megaparsec` error type.

versioning :: Text -> Either ParsingError Versioning Source #

Parse a piece of `Text` into either an (Ideal) `SemVer`, a (General) `Version`, or a (Complex) `Mess`.

semver :: Text -> Either ParsingError SemVer Source #

Parse a (Ideal) Semantic Version.

pvp :: Text -> Either ParsingError PVP Source #

Parse a (Haskell) `PVP`, as defined above.

version :: Text -> Either ParsingError Version Source #

Parse a (General) `Version`, as defined above.

mess :: Text -> Either ParsingError Mess Source #

Parse a (Complex) `Mess`, as defined above.

## Megaparsec Parsers

For when you'd like to mix version parsing into some larger parser.

versioning' :: Parsec Void Text Versioning Source #

Parse a `Versioning`. Assumes the version number is the last token in the string.

semver' :: Parsec Void Text SemVer Source #

Internal megaparsec parser of `semver`.

pvp' :: Parsec Void Text PVP Source #

Internal megaparsec parser of `pvp`.

version' :: Parsec Void Text Version Source #

Internal megaparsec parser of `version`.

mess' :: Parsec Void Text Mess Source #

Internal megaparsec parser of `mess`.

# Pretty Printing

prettyV :: Versioning -> Text Source #

Convert any parsed Versioning type to its textual representation.

prettySemVer :: SemVer -> Text Source #

Convert a `SemVer` back to its textual representation.

prettyPVP :: PVP -> Text Source #

Convert a `PVP` back to its textual representation.

prettyVer :: Version -> Text Source #

Convert a `Version` back to its textual representation.

prettyMess :: Mess -> Text Source #

Convert a `Mess` back to its textual representation.

errorBundlePretty Source #

Arguments

:: (VisualStream s, TraversableStream s, ShowErrorComponent e) |
=> ParseErrorBundle s e | Parse error bundle to display
-> String | Textual rendition of the bundle

Pretty-print a `ParseErrorBundle`. All `ParseError`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 `String` always ends with a newline.

Since: megaparsec-7.0.0

# Lenses

type Lens' s a = forall f. Functor f => (a -> f a) -> s -> f s Source #

Simple Lenses compatible with both lens and microlens.

type Traversal' s a = forall f. Applicative f => (a -> f a) -> s -> f s Source #

Simple Traversals compatible with both lens and microlens.

class Semantic v where Source #

Version types which sanely and safely yield `SemVer`-like information about themselves. For instances other than `SemVer` itself however, these optics may not yield anything, depending on the actual value being traversed. Hence, the optics here are all `Traversal'`s.

Consider the `Version` `1.2.3.4.5`. We can imagine wanting to increment the minor number:

    λ "1.2.3.4.5" & minor %~ (+ 1)
    "1.3.3.4.5"

But of course something like this would fail:

    λ "1.e.3.4.5" & minor %~ (+ 1)
    "1.e.3.4.5"

However!

    λ "1.e.3.4.5" & major %~ (+ 1)
    "2.e.3.4.5"

Methods

major :: Traversal' v Word Source #

    MAJOR.minor.patch-prerel+meta

minor :: Traversal' v Word Source #

    major.MINOR.patch-prerel+meta

patch :: Traversal' v Word Source #

    major.minor.PATCH-prerel+meta

release :: Traversal' v (Maybe Release) Source #

    major.minor.patch-PREREL+meta

meta :: Traversal' v (Maybe Text) Source #

    major.minor.patch-prerel+META

semantic :: Traversal' v SemVer Source #

A Natural Transformation into an proper `SemVer`.

#### Instances

Instances details

Semantic Text Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' Text Word Source # minor :: Traversal' Text Word Source # patch :: Traversal' Text Word Source # release :: Traversal' Text (Maybe Release) Source # meta :: Traversal' Text (Maybe Text) Source # semantic :: Traversal' Text SemVer Source #
Semantic Mess Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' Mess Word Source # minor :: Traversal' Mess Word Source # patch :: Traversal' Mess Word Source # release :: Traversal' Mess (Maybe Release) Source # meta :: Traversal' Mess (Maybe Text) Source # semantic :: Traversal' Mess SemVer Source #
Semantic PVP Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' PVP Word Source # minor :: Traversal' PVP Word Source # patch :: Traversal' PVP Word Source # release :: Traversal' PVP (Maybe Release) Source # meta :: Traversal' PVP (Maybe Text) Source # semantic :: Traversal' PVP SemVer Source #
Semantic SemVer Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' SemVer Word Source # minor :: Traversal' SemVer Word Source # patch :: Traversal' SemVer Word Source # release :: Traversal' SemVer (Maybe Release) Source # meta :: Traversal' SemVer (Maybe Text) Source # semantic :: Traversal' SemVer SemVer Source #
Semantic Version Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' Version Word Source # minor :: Traversal' Version Word Source # patch :: Traversal' Version Word Source # release :: Traversal' Version (Maybe Release) Source # meta :: Traversal' Version (Maybe Text) Source # semantic :: Traversal' Version SemVer Source #
Semantic Versioning Source # |
Instance details Defined in Data.Versions Methods major :: Traversal' Versioning Word Source # minor :: Traversal' Versioning Word Source # patch :: Traversal' Versioning Word Source # release :: Traversal' Versioning (Maybe Release) Source # meta :: Traversal' Versioning (Maybe Text) Source # semantic :: Traversal' Versioning SemVer Source #

## Traversing Text

When traversing `Text`, leveraging its `Semantic` instance will likely benefit you more than using these Traversals directly.

_Versioning :: Traversal' Text Versioning Source #

Traverse some Text for its inner versioning.

    λ "1.2.3" & _Versioning . _Ideal . patch %~ (+ 1)  -- or just: "1.2.3" & patch %~ (+ 1)
    "1.2.4"

_SemVer :: Traversal' Text SemVer Source #

Traverse some Text for its inner SemVer.

_Version :: Traversal' Text Version Source #

Traverse some Text for its inner Version.

_Mess :: Traversal' Text Mess Source #

Traverse some Text for its inner Mess.

## Versioning Traversals

_Ideal :: Traversal' Versioning SemVer Source #

Possibly extract a `SemVer` from a `Versioning`.

_General :: Traversal' Versioning Version Source #

Possibly extract a `Version` from a `Versioning`.

_Complex :: Traversal' Versioning Mess Source #

Possibly extract a `Mess` from a `Versioning`.

## (General) Version Lenses

epoch :: Lens' Version (Maybe Word) Source #

A `Version`'s inner epoch `Word`.