diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-01-02 18:07:10 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-01-02 18:07:10 +0000 |
commit | 1092316ba04116d7ae1d4cdf347804feacef768a (patch) | |
tree | fbc819794d4202a4ac778f0f6be57eedef7518dd /Utility/DottedVersion.hs | |
parent | d1e0531dd8e8b842349421a898b74b212d2157e8 (diff) | |
parent | 50a5a7b101cc9c30a5a04b4c20cbf7f99fcab0ef (diff) | |
download | git-repair-1092316ba04116d7ae1d4cdf347804feacef768a.tar.gz |
Merge tag '1.20200102'
tagging package git-repair version 1.20200102
Diffstat (limited to 'Utility/DottedVersion.hs')
-rw-r--r-- | Utility/DottedVersion.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Utility/DottedVersion.hs b/Utility/DottedVersion.hs index ebf4c0b..dff3717 100644 --- a/Utility/DottedVersion.hs +++ b/Utility/DottedVersion.hs @@ -7,7 +7,11 @@ {-# OPTIONS_GHC -fno-warn-tabs #-} -module Utility.DottedVersion where +module Utility.DottedVersion ( + DottedVersion, + fromDottedVersion, + normalize, +) where import Common @@ -18,14 +22,17 @@ instance Ord DottedVersion where compare (DottedVersion _ x) (DottedVersion _ y) = compare x y instance Show DottedVersion where - show (DottedVersion s _) = s + show = fromDottedVersion + +fromDottedVersion :: DottedVersion -> String +fromDottedVersion (DottedVersion s _) = s {- To compare dotted versions like 1.7.7 and 1.8, they are normalized to - a somewhat arbitrary integer representation. -} normalize :: String -> DottedVersion normalize v = DottedVersion v $ sum $ mult 1 $ reverse $ extend precision $ take precision $ - map readi $ split "." v + map readi $ splitc '.' v where extend n l = l ++ replicate (n - length l) 0 mult _ [] = [] |