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

Malcolm Wallace Malcolm.Wallace at
Fri Oct 26 06:46:34 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

Simon Marlow <simonmarhaskell at> wrote:

> I see advantages and disadvantages.
> Advantages:
>   * matches intuitive understanding of versions
>   * lets us drop trailing zeroes in version numbers
> Disadvantages:
>   * version ordering is slightly harder to explain

Pretty much, yes.  Although arguably the disadvantage is not so bad,
since currently one has to explain why 1.2.0 is _not_ the same as 1.2.

> Is there a precedent anywhere else for doing this?

I could point to ordinary decimal notation, where 1.2000 == 1.2.

Perl has a related notion of implicit zero-extension in the "version" pod:

Microsoft's .NET Framework seems to ignore trailing zeros in versions:

wxWidgets release numbers sometimes omit trailing zeros:

I found proposals to ignore trailing zeros in version comparisons
within OpenOffice, Python distutils, and Drupal:

> Wouldn't the implementation be simpler if you added a
> dropTrailingZeros  function, and just applied it before comparing? 

Yes, that is another possible implementation.  It involves traversing
both version structures twice rather than once (but I don't suppose the
slight efficiency loss would ever be noticable).


More information about the Libraries mailing list