Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Malcolm Wallace <Malcolm.Wallace <at> cs.york.ac.uk>
Subject: proposal: in base, for Data.Version, change the meaning of comparisons
Newsgroups: gmane.comp.lang.haskell.libraries
Date: Thursday 25th October 2007 16:19:00 UTC (over 9 years ago)
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.
[email protected]**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 **20071024090947
 I was using a recent build here, which is more tolerant.
] 
[FIX #1258: document that openTempFile is secure(ish)
Simon Marlow **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 **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 **20071007150408] 
[FIX #1652: openTempFile should accept an empty string for the directory
Simon Marlow **20071018122345] 
[clean up duplicate code
Simon Marlow **20071017141311] 
[expose the value of +RTS -N as GHC.Conc.numCapabilities (see #1733)
Simon Marlow **20071009132042] 
[typo
Simon Marlow **20070917130703] 
[put extra-tmp-files field in the right place
Simon Marlow **20070914140812] 
[Add more entries to boring file
Ian Lynagh **20070913210500] 
[Add a boring file
Ian Lynagh **20070913204641] 
[TAG 2007-09-13
Ian Lynagh **20070913215720] 
Patch bundle hash:
fe636959d9254b8fabd6e7ad6926a4d0b7ee0d15
 
CD: 3ms