proposal: in base, for Data.Version, change the meaning of comparisons

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Thu Oct 25 12:19:00 EDT 2007


Proposal: that values of the type Data.Version.Version should compare
equal, by ignoring trailing zeros.
Thus 1.2.0 == 1.2, rather than 1.2.0 > 1.2

Regards,
    Malcolm

----
New patches:

[In Data.Version, make equality comparisons independent of trailing zeros.
Malcolm.Wallace at cs.york.ac.uk**20071025161240] {
hunk ./Data/Version.hs 122
-  v1 == v2  =  versionBranch v1 == versionBranch v2 
+  v1 == v2  =  branchEq (versionBranch v1) (versionBranch v2)
hunk ./Data/Version.hs 125
+  where
+    branchEq :: [Int] -> [Int] -> Bool
+    branchEq [] [] = True
+    branchEq vs [] = all (==0) vs
+    branchEq [] vs = all (==0) vs
+    branchEq (v:vs) (w:ws) = v==w && branchEq vs ws
hunk ./Data/Version.hs 133
-  v1 `compare` v2 = versionBranch v1 `compare` versionBranch v2
-
+  v1 `compare` v2 = versionBranch v1 `cmpBranch` versionBranch v2
+  where
+    cmpBranch [] [] = EQ
+    cmpBranch vs [] | all (==0) vs = EQ
+                    | otherwise    = GT
+    cmpBranch [] vs | all (==0) vs = EQ
+                    | otherwise    = LT
+    cmpBranch (v:vs) (w:ws) | v==w = cmpBranch vs ws
+                            | otherwise = compare v w
+
}

Context:

[Fix doc building with Haddock 0.9
Simon Marlow <simonmar at microsoft.com>**20071024090947
 I was using a recent build here, which is more tolerant.
] 
[FIX #1258: document that openTempFile is secure(ish)
Simon Marlow <simonmar at microsoft.com>**20071023130928
 Also change the mode from 0666 to 0600, which seems like a more
 sensible value and matches what C's mkstemp() does.
] 
[Clean up .cabal file a bit
Duncan Coutts <duncan at haskell.org>**20071022132708
 specify build-type and cabal-version >= 1.2
 put extra-tmp-files in the right place
 use os(windows) rather than os(mingw32)
] 
[base in 6.8 and head branch should be version 3.0
Don Stewart <dons at galois.com>**20071007150408] 
[FIX #1652: openTempFile should accept an empty string for the directory
Simon Marlow <simonmar at microsoft.com>**20071018122345] 
[clean up duplicate code
Simon Marlow <simonmar at microsoft.com>**20071017141311] 
[expose the value of +RTS -N as GHC.Conc.numCapabilities (see #1733)
Simon Marlow <simonmar at microsoft.com>**20071009132042] 
[typo
Simon Marlow <simonmar at microsoft.com>**20070917130703] 
[put extra-tmp-files field in the right place
Simon Marlow <simonmar at microsoft.com>**20070914140812] 
[Add more entries to boring file
Ian Lynagh <igloo at earth.li>**20070913210500] 
[Add a boring file
Ian Lynagh <igloo at earth.li>**20070913204641] 
[TAG 2007-09-13
Ian Lynagh <igloo at earth.li>**20070913215720] 
Patch bundle hash:
fe636959d9254b8fabd6e7ad6926a4d0b7ee0d15


More information about the Libraries mailing list