| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Version.Package.Internal
Description
Internal module.
Since: 0.1.0.0
Synopsis
- newtype PackageVersion = MkPackageVersion {}
- data ValidationError
- data ReadStringError
- data ReadFileError
- mkPackageVersion :: [Int] -> Either ValidationError PackageVersion
- toText :: PackageVersion -> Text
Documentation
newtype PackageVersion Source #
PackageVersion represents PVP version
numbers. It is similar to Data.Version's Version except:
PackageVersionhas noversionTags.We enforce PVP invariants i.e.
- Tags must have at least one component.
- All components >= 0.
- Trailing zeroes are ignored in
Eq,Ord,Semigroup, andMonoid.
That is, we declare an equivalence class up to trailing zeroes.
In particular, the Monoid identity is
[0] = { [0], [0,0], [0,0,0], ... }
and its Semigroup instance takes the greatest version (based on Ord).
Note: Because we export the underlying list in various ways,
(e.g. show), Eq's extensionality law,
x == y ==> f x == f y
can be broken. Take care that you do not rely on this law if you are
using its underlying NonEmpty (or WordString) representation.
Examples
>>>MkPackageVersion [0,0,0,0] == MkPackageVersion [0,0,0]True
>>>MkPackageVersion [4,0,0] > MkPackageVersion [1,2,0,0]True
>>>MkPackageVersion [5,6,0] <> MkPackageVersion [9,0,0]MkPackageVersion {unPackageVersion = 9 :| [0,0]}
>>>MkPackageVersion [0,9] <> MkPackageVersion [0,9,0,0]MkPackageVersion {unPackageVersion = 0 :| [9]}
Since: 0.1.0.0
Constructors
| MkPackageVersion | |
Fields
| |
Instances
data ValidationError Source #
Errors that can occur when validating PVP version numbers.
Since: 0.1.0.0
Constructors
| ValidationErrorEmpty | PVP version number cannot be empty. Since: 0.3 |
| ValidationErrorNegative Int | PVP version numbers cannot be negative. Since: 0.2 |
Instances
| Exception ValidationError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal Methods toException :: ValidationError -> SomeException # | |||||
| Generic ValidationError Source # | |||||
Defined in Data.Version.Package.Internal Associated Types
Methods from :: ValidationError -> Rep ValidationError x # to :: Rep ValidationError x -> ValidationError # | |||||
| Show ValidationError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal Methods showsPrec :: Int -> ValidationError -> ShowS # show :: ValidationError -> String # showList :: [ValidationError] -> ShowS # | |||||
| NFData ValidationError Source # | Since: 0.2 | ||||
Defined in Data.Version.Package.Internal Methods rnf :: ValidationError -> () # | |||||
| Eq ValidationError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal Methods (==) :: ValidationError -> ValidationError -> Bool # (/=) :: ValidationError -> ValidationError -> Bool # | |||||
| type Rep ValidationError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal type Rep ValidationError = D1 ('MetaData "ValidationError" "Data.Version.Package.Internal" "package-version-0.4-inplace" 'False) (C1 ('MetaCons "ValidationErrorEmpty" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ValidationErrorNegative" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) | |||||
data ReadStringError Source #
Errors that can occur when reading PVP version numbers.
Since: 0.1.0.0
Constructors
| ReadStringErrorParse String | Error when parsing a string. Since: 0.2 |
| ReadStringErrorValidate ValidationError | Validation error. Since: 0.2 |
Instances
| Exception ReadStringError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal Methods toException :: ReadStringError -> SomeException # | |||||
| Generic ReadStringError Source # | |||||
Defined in Data.Version.Package.Internal Associated Types
Methods from :: ReadStringError -> Rep ReadStringError x # to :: Rep ReadStringError x -> ReadStringError # | |||||
| Show ReadStringError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal Methods showsPrec :: Int -> ReadStringError -> ShowS # show :: ReadStringError -> String # showList :: [ReadStringError] -> ShowS # | |||||
| NFData ReadStringError Source # | Since: 0.2 | ||||
Defined in Data.Version.Package.Internal Methods rnf :: ReadStringError -> () # | |||||
| Eq ReadStringError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal Methods (==) :: ReadStringError -> ReadStringError -> Bool # (/=) :: ReadStringError -> ReadStringError -> Bool # | |||||
| type Rep ReadStringError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal type Rep ReadStringError = D1 ('MetaData "ReadStringError" "Data.Version.Package.Internal" "package-version-0.4-inplace" 'False) (C1 ('MetaCons "ReadStringErrorParse" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "ReadStringErrorValidate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ValidationError))) | |||||
data ReadFileError Source #
Errors that can occur when reading PVP version numbers from a file.
Since: 0.1.0.0
Constructors
| ReadFileErrorGeneral String | General error when reading a file. Since: 0.2 |
| ReadFileErrorVersionNotFound FilePath | Error for missing version. Since: 0.2 |
| ReadFileErrorReadString ReadStringError | Read/Validation error. Since: 0.2 |
Instances
| Exception ReadFileError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal Methods toException :: ReadFileError -> SomeException # fromException :: SomeException -> Maybe ReadFileError # displayException :: ReadFileError -> String # | |||||
| Generic ReadFileError Source # | |||||
Defined in Data.Version.Package.Internal Associated Types
| |||||
| Show ReadFileError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal Methods showsPrec :: Int -> ReadFileError -> ShowS # show :: ReadFileError -> String # showList :: [ReadFileError] -> ShowS # | |||||
| NFData ReadFileError Source # | Since: 0.2 | ||||
Defined in Data.Version.Package.Internal Methods rnf :: ReadFileError -> () # | |||||
| Eq ReadFileError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal Methods (==) :: ReadFileError -> ReadFileError -> Bool # (/=) :: ReadFileError -> ReadFileError -> Bool # | |||||
| type Rep ReadFileError Source # | Since: 0.1.0.0 | ||||
Defined in Data.Version.Package.Internal type Rep ReadFileError = D1 ('MetaData "ReadFileError" "Data.Version.Package.Internal" "package-version-0.4-inplace" 'False) (C1 ('MetaCons "ReadFileErrorGeneral" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: (C1 ('MetaCons "ReadFileErrorVersionNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)) :+: C1 ('MetaCons "ReadFileErrorReadString" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReadStringError)))) | |||||
mkPackageVersion :: [Int] -> Either ValidationError PackageVersion Source #
Constructs a PackageVersion from an Int list. The list must be
non-empty to match PVP's minimal A. Furthermore, all digits must be
non-negative.
Examples
>>>mkPackageVersion [1,2]Right (MkPackageVersion {unPackageVersion = 1 :| [2]})
>>>mkPackageVersion [2,87,7,1]Right (MkPackageVersion {unPackageVersion = 2 :| [87,7,1]})
>>>mkPackageVersion [1,2,-3,-4,5]Left (ValidationErrorNegative (-3))
>>>mkPackageVersion [3]Right (MkPackageVersion {unPackageVersion = 3 :| []})
>>>mkPackageVersion []Left ValidationErrorEmpty
Since: 0.1.0.0
toText :: PackageVersion -> Text Source #
Displays PackageVersion in Text format.
Examples
>>>toText (MkPackageVersion [2,7,10,0])"2.7.10.0"
Since: 0.1.0.0