Data.SemVer

semver-range-0.2.8: An implementation of semver and semantic version ranges.

Safe Haskell | None
Language | Haskell2010

Data.SemVer

Synopsis

- data SemVerRange
  - = Eq SemVer
  - | Gt SemVer
  - | Lt SemVer
  - | Geq SemVer
  - | Leq SemVer
  - | And SemVerRange SemVerRange
  - | Or SemVerRange SemVerRange
- data SemVer = SemVer {
  - svMajor :: !Int
  - svMinor :: !Int
  - svPatch :: !Int
  - svTags :: !PrereleaseTags
  - svBuildMetadata :: !BuildMetaData
  }
- data PrereleaseTag
  - = IntTag Int
  - | TextTag Text
- newtype PrereleaseTags = PrereleaseTags [PrereleaseTag]
- type BuildMetaData = [Text]
- versionsOf :: SemVerRange -> [SemVer]
- stripRangeTags :: SemVerRange -> SemVerRange
- semver :: Int -> Int -> Int -> SemVer
- semver' :: Int -> Int -> Int -> PrereleaseTags -> SemVer
- semver'' :: Int -> Int -> Int -> PrereleaseTags -> BuildMetaData -> SemVer
- toTuple :: SemVer -> (Int, Int, Int)
- tuplesOf :: SemVerRange -> [(Int, Int, Int)]
- rangePrereleaseTags :: SemVerRange -> PrereleaseTags
- sharedTags :: SemVerRange -> Maybe PrereleaseTags
- anyVersion :: SemVerRange
- renderSV :: SemVer -> Text
- matches :: SemVerRange -> SemVer -> Bool
- matchesSimple :: SemVerRange -> SemVer -> Bool
- matchesTags :: SemVerRange -> PrereleaseTags -> PrereleaseTags -> Bool
- bestMatch :: SemVerRange -> [SemVer] -> Either String SemVer
- parseSemVer :: Text -> Either ParseError SemVer
- parseSemVerRange :: Text -> Either ParseError SemVerRange
- pSemVerRange :: Parser SemVerRange
- pSemVer :: Parser SemVer
- fromHaskellVersion :: Version -> Either Text SemVer
- matchText :: Text -> Text -> Either Text Bool
- splitWS :: Text -> [Text]

# Documentation

data SemVerRange #

A range specifies bounds on a semver.

Constructors

Eq SemVer infixl 4 | Exact equality
Gt SemVer infixl 4 | Greater than
Lt SemVer infixl 4 | Less than
Geq SemVer infixl 4 | Greater than or equal to
Leq SemVer infixl 4 | Less than or equal to
And SemVerRange SemVerRange infixl 3 | Conjunction
Or SemVerRange SemVerRange infixl 3 | Disjunction

#### Instances

Instances details

Show SemVerRange # |
Instance details Defined in Data.SemVer.Types Methods showsPrec :: Int -> SemVerRange -> ShowS # show :: SemVerRange -> String # showList :: [SemVerRange] -> ShowS #
Eq SemVerRange # |
Instance details Defined in Data.SemVer.Types Methods (==) :: SemVerRange -> SemVerRange -> Bool # (/=) :: SemVerRange -> SemVerRange -> Bool #
Ord SemVerRange # |
Instance details Defined in Data.SemVer.Types Methods compare :: SemVerRange -> SemVerRange -> Ordering # (<) :: SemVerRange -> SemVerRange -> Bool # (<=) :: SemVerRange -> SemVerRange -> Bool # (>) :: SemVerRange -> SemVerRange -> Bool # (>=) :: SemVerRange -> SemVerRange -> Bool # max :: SemVerRange -> SemVerRange -> SemVerRange # min :: SemVerRange -> SemVerRange -> SemVerRange #

data SemVer #

A SemVer has major, minor and patch versions, and zero or more pre-release version tags.

Constructors

SemVer |
Fields svMajor :: !Int svMinor :: !Int svPatch :: !Int svTags :: !PrereleaseTags svBuildMetadata :: !BuildMetaData

#### Instances

Instances details

Generic SemVer # |
Instance details Defined in Data.SemVer.Types Associated Types
type Rep SemVer |
Instance details Defined in Data.SemVer.Types type Rep SemVer = D1 ('MetaData "SemVer" "Data.SemVer.Types" "semver-range-0.2.8-BO1aYEJH2UVKvLdfP8lDgR" 'False) (C1 ('MetaCons "SemVer" 'PrefixI 'True) ((S1 ('MetaSel ('Just "svMajor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "svMinor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "svPatch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: (S1 ('MetaSel ('Just "svTags") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PrereleaseTags) :*: S1 ('MetaSel ('Just "svBuildMetadata") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 BuildMetaData)))))
Methods from :: SemVer -> Rep SemVer x # to :: Rep SemVer x -> SemVer #
Show SemVer # |
Instance details Defined in Data.SemVer.Types Methods showsPrec :: Int -> SemVer -> ShowS # show :: SemVer -> String # showList :: [SemVer] -> ShowS #
Eq SemVer # |
Instance details Defined in Data.SemVer.Types Methods (==) :: SemVer -> SemVer -> Bool # (/=) :: SemVer -> SemVer -> Bool #
Ord SemVer # | Define an Ord instance which ignores the buildMetaData.
Instance details Defined in Data.SemVer.Types Methods compare :: SemVer -> SemVer -> Ordering # (<) :: SemVer -> SemVer -> Bool # (<=) :: SemVer -> SemVer -> Bool # (>) :: SemVer -> SemVer -> Bool # (>=) :: SemVer -> SemVer -> Bool # max :: SemVer -> SemVer -> SemVer # min :: SemVer -> SemVer -> SemVer #
Hashable SemVer # |
Instance details Defined in Data.SemVer.Types Methods hashWithSalt :: Int -> SemVer -> Int # hash :: SemVer -> Int #
type Rep SemVer # |
Instance details Defined in Data.SemVer.Types type Rep SemVer = D1 ('MetaData "SemVer" "Data.SemVer.Types" "semver-range-0.2.8-BO1aYEJH2UVKvLdfP8lDgR" 'False) (C1 ('MetaCons "SemVer" 'PrefixI 'True) ((S1 ('MetaSel ('Just "svMajor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "svMinor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "svPatch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: (S1 ('MetaSel ('Just "svTags") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PrereleaseTags) :*: S1 ('MetaSel ('Just "svBuildMetadata") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 BuildMetaData)))))

data PrereleaseTag #

Prerelease tags can either be numbers or text.

Constructors

IntTag Int |
TextTag Text |

#### Instances

Instances details

IsString PrereleaseTag # |
Instance details Defined in Data.SemVer.Types Methods fromString :: String -> PrereleaseTag #
Generic PrereleaseTag # |
Instance details Defined in Data.SemVer.Types Associated Types
type Rep PrereleaseTag |
Instance details Defined in Data.SemVer.Types type Rep PrereleaseTag = D1 ('MetaData "PrereleaseTag" "Data.SemVer.Types" "semver-range-0.2.8-BO1aYEJH2UVKvLdfP8lDgR" 'False) (C1 ('MetaCons "IntTag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: C1 ('MetaCons "TextTag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))
Methods from :: PrereleaseTag -> Rep PrereleaseTag x # to :: Rep PrereleaseTag x -> PrereleaseTag #
Show PrereleaseTag # |
Instance details Defined in Data.SemVer.Types Methods showsPrec :: Int -> PrereleaseTag -> ShowS # show :: PrereleaseTag -> String # showList :: [PrereleaseTag] -> ShowS #
Eq PrereleaseTag # |
Instance details Defined in Data.SemVer.Types Methods (==) :: PrereleaseTag -> PrereleaseTag -> Bool # (/=) :: PrereleaseTag -> PrereleaseTag -> Bool #
Ord PrereleaseTag # |
Instance details Defined in Data.SemVer.Types Methods compare :: PrereleaseTag -> PrereleaseTag -> Ordering # (<) :: PrereleaseTag -> PrereleaseTag -> Bool # (<=) :: PrereleaseTag -> PrereleaseTag -> Bool # (>) :: PrereleaseTag -> PrereleaseTag -> Bool # (>=) :: PrereleaseTag -> PrereleaseTag -> Bool # max :: PrereleaseTag -> PrereleaseTag -> PrereleaseTag # min :: PrereleaseTag -> PrereleaseTag -> PrereleaseTag #
Hashable PrereleaseTag # |
Instance details Defined in Data.SemVer.Types Methods hashWithSalt :: Int -> PrereleaseTag -> Int # hash :: PrereleaseTag -> Int #
type Rep PrereleaseTag # |
Instance details Defined in Data.SemVer.Types type Rep PrereleaseTag = D1 ('MetaData "PrereleaseTag" "Data.SemVer.Types" "semver-range-0.2.8-BO1aYEJH2UVKvLdfP8lDgR" 'False) (C1 ('MetaCons "IntTag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: C1 ('MetaCons "TextTag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

newtype PrereleaseTags #

Constructors

PrereleaseTags [PrereleaseTag] |

#### Instances

Instances details

Monoid PrereleaseTags # |
Instance details Defined in Data.SemVer.Types Methods mempty :: PrereleaseTags # mappend :: PrereleaseTags -> PrereleaseTags -> PrereleaseTags # mconcat :: [PrereleaseTags] -> PrereleaseTags #
Semigroup PrereleaseTags # |
Instance details Defined in Data.SemVer.Types Methods (<>) :: PrereleaseTags -> PrereleaseTags -> PrereleaseTags # sconcat :: NonEmpty PrereleaseTags -> PrereleaseTags # stimes :: Integral b => b -> PrereleaseTags -> PrereleaseTags #
Generic PrereleaseTags # |
Instance details Defined in Data.SemVer.Types Associated Types
type Rep PrereleaseTags |
Instance details Defined in Data.SemVer.Types type Rep PrereleaseTags = D1 ('MetaData "PrereleaseTags" "Data.SemVer.Types" "semver-range-0.2.8-BO1aYEJH2UVKvLdfP8lDgR" 'True) (C1 ('MetaCons "PrereleaseTags" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [PrereleaseTag])))
Methods from :: PrereleaseTags -> Rep PrereleaseTags x # to :: Rep PrereleaseTags x -> PrereleaseTags #
IsList PrereleaseTags # |
Instance details Defined in Data.SemVer.Types Associated Types
type Item PrereleaseTags |
Instance details Defined in Data.SemVer.Types type Item PrereleaseTags = PrereleaseTag
Methods fromList :: [Item PrereleaseTags] -> PrereleaseTags # fromListN :: Int -> [Item PrereleaseTags] -> PrereleaseTags # toList :: PrereleaseTags -> [Item PrereleaseTags] #
Show PrereleaseTags # |
Instance details Defined in Data.SemVer.Types Methods showsPrec :: Int -> PrereleaseTags -> ShowS # show :: PrereleaseTags -> String # showList :: [PrereleaseTags] -> ShowS #
Eq PrereleaseTags # |
Instance details Defined in Data.SemVer.Types Methods (==) :: PrereleaseTags -> PrereleaseTags -> Bool # (/=) :: PrereleaseTags -> PrereleaseTags -> Bool #
Ord PrereleaseTags # |
Instance details Defined in Data.SemVer.Types Methods compare :: PrereleaseTags -> PrereleaseTags -> Ordering # (<) :: PrereleaseTags -> PrereleaseTags -> Bool # (<=) :: PrereleaseTags -> PrereleaseTags -> Bool # (>) :: PrereleaseTags -> PrereleaseTags -> Bool # (>=) :: PrereleaseTags -> PrereleaseTags -> Bool # max :: PrereleaseTags -> PrereleaseTags -> PrereleaseTags # min :: PrereleaseTags -> PrereleaseTags -> PrereleaseTags #
Hashable PrereleaseTags # |
Instance details Defined in Data.SemVer.Types Methods hashWithSalt :: Int -> PrereleaseTags -> Int # hash :: PrereleaseTags -> Int #
type Rep PrereleaseTags # |
Instance details Defined in Data.SemVer.Types type Rep PrereleaseTags = D1 ('MetaData "PrereleaseTags" "Data.SemVer.Types" "semver-range-0.2.8-BO1aYEJH2UVKvLdfP8lDgR" 'True) (C1 ('MetaCons "PrereleaseTags" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [PrereleaseTag])))
type Item PrereleaseTags # |
Instance details Defined in Data.SemVer.Types type Item PrereleaseTags = PrereleaseTag

type BuildMetaData = [Text] #

versionsOf :: SemVerRange -> [SemVer] #

Pull all of the concrete versions out of a range.

stripRangeTags :: SemVerRange -> SemVerRange #

Strip out all prerelease tags from a given `SemVerRange`.

semver :: Int -> Int -> Int -> SemVer #

Create a SemVer with no version tags.

semver' :: Int -> Int -> Int -> PrereleaseTags -> SemVer #

Create a SemVer with tags

semver'' :: Int -> Int -> Int -> PrereleaseTags -> BuildMetaData -> SemVer #

Create a SemVer with tags and metadata.

toTuple :: SemVer -> (Int, Int, Int) #

Get only the version tuple from a semver.

tuplesOf :: SemVerRange -> [(Int, Int, Int)] #

Get a list of tuples from a version range.

rangePrereleaseTags :: SemVerRange -> PrereleaseTags #

Get all of the prerelease tags from a version range.

sharedTags :: SemVerRange -> Maybe PrereleaseTags #

Get the range prerelease tags if they're all the same; otherwise Nothing.

anyVersion :: SemVerRange #

Satisfies any version.

renderSV :: SemVer -> Text #

Render a semver as Text.

matches :: SemVerRange -> SemVer -> Bool infixl 2 #

Returns whether a given semantic version matches a range. Note that there are special cases when there are prerelease tags. For details see https://github.com/npm/node-semver#prerelease-tags.

matchesSimple :: SemVerRange -> SemVer -> Bool #

Simple predicate calculus matching, doing AND and OR combination with numerical comparison.

matchesTags :: SemVerRange -> PrereleaseTags -> PrereleaseTags -> Bool #

Given a range and two sets of tags, the first being a bound on the second, uses the range to compare the tags and see if they match.

bestMatch :: SemVerRange -> [SemVer] -> Either String SemVer #

Gets the highest-matching semver in a range.

parseSemVer :: Text -> Either ParseError SemVer #

Parse a string as an explicit version, or return an error.

parseSemVerRange :: Text -> Either ParseError SemVerRange #

Parse a string as a version range, or return an error.

pSemVerRange :: Parser SemVerRange #

Top-level parser. Parses a semantic version range.

pSemVer :: Parser SemVer #

Parses a semantic version.

fromHaskellVersion :: Version -> Either Text SemVer #

Parse a semver from a haskell version. There must be exactly three numbers in the versionBranch field.

matchText :: Text -> Text -> Either Text Bool #

Parses the first argument as a range and the second argument as a semver, and returns whether they match.

splitWS :: Text -> [Text] #

Split a text on whitespace. Why isn't this in the stdlib.