Helpers for working with version strings in elm.json files.
Compare two versions:
v1 = fromString "1.0.0"
v2 = fromString "2.0.0"
v3 = fromString "3.0.0"
-- Maybe.map2 compare v1 v2 == Just LT
-- Maybe.map2 compare v2 v2 == Just EQ
-- Maybe.map2 compare v2 v1 == Just GTConvert a Version to a String that works in elm.json
toString one == "1.0.0"Try to convert a String into a Version. The major, minor, and patch
numbers must all appear separated by dots:
fromString "1.0.0" == Just one
fromString "2.0.0" == Just ...
fromString "3-0-0" == Nothing
fromString "3.0" == NothingTurn a Version into a tuple to extract the numbers as integers.
toTuple one == (1, 0, 0)
Maybe.map toTuple (fromString "2.0.4" ) == Just (2, 0, 4)
Maybe.map toTuple (fromString "7.3.10") == Just (7, 3, 10)Try to make a Version from given numbers. This way you do not need
to turn things into strings for no reason. It can still fail if you give
negative numbers or versions below 1.0.0:
fromTuple (1, 0, 0) == Just one
fromTuple (2, 0, 1) == Just ...
fromTuple (0, 0, 1) == Nothing
A guaranteed valid Elm version. All versions are
1.0.0or greater.