Data.Version.parseVersion

Simon Marlow simonmar at microsoft.com
Wed Jan 4 08:07:30 EST 2006


Einar Karttunen wrote:

> What is the correct way to use Data.Version.parseVersion?
> It seems to start with the "wrong" result and the last one
> is the intended one. e.g. "1.2.3" is parsed as:
> 
> [(Version {versionBranch = [1], versionTags = []},".2.3"),
>  (Version {versionBranch = [1,2], versionTags = []},".3"),
>  (Version {versionBranch = [1,2,3], versionTags = []},"")]
> 
> This is different from the usual read instances. Is the
> behaviour intended? Should I just use that as:
> 
> filter (null . snd) $ readP_to_S parseVersion "1.2.3" :: [(Version,String)]

It was intentional, but I'm prepared to be persuaded that it should be 
done differently.  The problem is that all the parses are valid, it just 
depends how much of the string you want to munch.  Perhaps the parser 
should just be greedy.

You can't really compare this to other Read instances - for good reasons 
this isn't the Read insance for Data.Version.  It's just a custom parser 
for versions.

Cheers,
	Simon



More information about the Libraries mailing list