Helpers for working with version constraint strings in elm.json files.
Check if a version is within the given constraint:
import Elm.Version as V
oneToTwo = fromString "1.0.0 <= v < 2.0.0"
sixToTen = fromString "6.0.0 <= v < 10.0.0"
-- Maybe.map (check V.one) oneToTwo == Just True
-- Maybe.map (check V.one) sixToTen == Just FalseConvert a Constraint to a String that works in elm.json
Try to convert a String into a Constraint:
fromString "1.0.0 <= v < 2.0.0" == Just ...
fromString "1.0.0 <= v < 10.0.0" == Just ...
fromString "1.0.0 <= v <= 1.0.0" == Just ...
fromString "1.0.0" == Nothing
fromString "1.0.0 <= 2.0.0" == Nothing
fromString "1.0.0 <= v < 2.0.0" == Nothing -- extra spaces
fromString "1.0.0 <= vsn < 2.0.0" == Nothing -- not "v" only
fromString "2.0.0 <= v < 1.0.0" == Nothing -- unsatisfiableTurn a Constraint into a string for use in elm.json
Decode the constraint strings that appear in elm.json
A guaranteed valid Elm constraint. That means the lower bound
v1and the upper boundv2are both validElm.Versionversions, andv1 <= v2is guaranteed.