cabal-fmt-0.1.12: Format .cabal files
Safe HaskellSafe-Inferred
LanguageHaskell2010

VersionInterval

Description

This module implements a view of a VersionRange as a finite list of separated version intervals.

In conversion from and to VersionRange it makes some effort to preserve the caret operator ^>=x.y. This constraint a priori specifies the same interval as ==x.y.*, but indicates that newer versions could be acceptable (allow-newer: ^).

Synopsis

Version intervals

data VersionIntervals Source #

A complementary representation of a VersionRange. Instead of a boolean version predicate it uses an increasing sequence of non-overlapping, non-empty intervals.

This version is different than in Cabal-3.8 and previous, as it tries to preserve ^>= version ranges under default and transformCaretUpper semantics. Slighly simplifying, normalizeVersionRange shouldn't destroy ^>= in version range expressions.

unVersionIntervals :: VersionIntervals -> [VersionInterval] Source #

Inspect the list of version intervals.

Conversions

toVersionIntervals :: VersionRange -> VersionIntervals Source #

Convert a VersionRange to a sequence of version intervals.

fromVersionIntervals :: VersionIntervals -> Either ConversionProblem VersionRange Source #

Convert a VersionIntervals value back into a VersionRange expression representing the version intervals.

Normalisation

Version intervals view

data VersionInterval Source #

Version interval.

Invariants:

  • Interval is non-empty
  • MB is between LB and UB.

Constructors

VI !LB !MB !UB 

Instances

Instances details
Show VersionInterval Source # 
Instance details

Defined in VersionInterval

Eq VersionInterval Source # 
Instance details

Defined in VersionInterval

data LB Source #

Lower bound. For intervals it always exist: zeroLB i.e. >= 0.

All lower bound intervals are inclusive, i.e. >=v. >x.y.z is converted into >=x.y.z.0.

Constructors

LB !Version 

Instances

Instances details
Show LB Source # 
Instance details

Defined in VersionInterval

Methods

showsPrec :: Int -> LB -> ShowS #

show :: LB -> String #

showList :: [LB] -> ShowS #

Eq LB Source # 
Instance details

Defined in VersionInterval

Methods

(==) :: LB -> LB -> Bool #

(/=) :: LB -> LB -> Bool #

Ord LB Source # 
Instance details

Defined in VersionInterval

Methods

compare :: LB -> LB -> Ordering #

(<) :: LB -> LB -> Bool #

(<=) :: LB -> LB -> Bool #

(>) :: LB -> LB -> Bool #

(>=) :: LB -> LB -> Bool #

max :: LB -> LB -> LB #

min :: LB -> LB -> LB #

data MB Source #

Middle bound.

Constructors

MB !Version

major bound.

NoMB

no major bound (i.e. infinite)

Instances

Instances details
Show MB Source # 
Instance details

Defined in VersionInterval

Methods

showsPrec :: Int -> MB -> ShowS #

show :: MB -> String #

showList :: [MB] -> ShowS #

Eq MB Source # 
Instance details

Defined in VersionInterval

Methods

(==) :: MB -> MB -> Bool #

(/=) :: MB -> MB -> Bool #

Ord MB Source # 
Instance details

Defined in VersionInterval

Methods

compare :: MB -> MB -> Ordering #

(<) :: MB -> MB -> Bool #

(<=) :: MB -> MB -> Bool #

(>) :: MB -> MB -> Bool #

(>=) :: MB -> MB -> Bool #

max :: MB -> MB -> MB #

min :: MB -> MB -> MB #

data UB Source #

Upper bound.

All upper bounds are exclusive, i.e. <v. <=x.y.z is converted to <x.y.z.0.

Constructors

UB !Version

upper bound

NoUB

no upper bound (i.e. infinite)

Instances

Instances details
Show UB Source # 
Instance details

Defined in VersionInterval

Methods

showsPrec :: Int -> UB -> ShowS #

show :: UB -> String #

showList :: [UB] -> ShowS #

Eq UB Source # 
Instance details

Defined in VersionInterval

Methods

(==) :: UB -> UB -> Bool #

(/=) :: UB -> UB -> Bool #

Ord UB Source # 
Instance details

Defined in VersionInterval

Methods

compare :: UB -> UB -> Ordering #

(<) :: UB -> UB -> Bool #

(<=) :: UB -> UB -> Bool #

(>) :: UB -> UB -> Bool #

(>=) :: UB -> UB -> Bool #

max :: UB -> UB -> UB #

min :: UB -> UB -> UB #

data Bound Source #

Bound variant.

Constructors

Incl

inclusive: >= or <=

Excl

exclusive: > or <

Instances

Instances details
Show Bound Source # 
Instance details

Defined in VersionInterval

Methods

showsPrec :: Int -> Bound -> ShowS #

show :: Bound -> String #

showList :: [Bound] -> ShowS #

Eq Bound Source # 
Instance details

Defined in VersionInterval

Methods

(==) :: Bound -> Bound -> Bool #

(/=) :: Bound -> Bound -> Bool #

Ord Bound Source # 
Instance details

Defined in VersionInterval

Methods

compare :: Bound -> Bound -> Ordering #

(<) :: Bound -> Bound -> Bool #

(<=) :: Bound -> Bound -> Bool #

(>) :: Bound -> Bound -> Bool #

(>=) :: Bound -> Bound -> Bool #

max :: Bound -> Bound -> Bound #

min :: Bound -> Bound -> Bound #

For testing

validVersionIntervals :: VersionIntervals -> Bool Source #

VersionIntervals invariant:

  • all intervals are valid (lower bound is less then upper bound, middle bound is in between)
  • intervals doesn't touch each other (distinct)