elm / project-metadata-utils / Elm.Package

Helpers for working with package name strings in elm.json files.

Packages


type Name

A guaranteed valid Elm package name.

String Conversions

toString : Name -> String

Convert a Name to a String that works in elm.json

fromString : String -> Maybe Name

Try to convert a String into a Name:

fromString "elm/core"    == Just ...
fromString "elm/html"    == Just ...
fromString "tom/elm-css" == Just ...
fromString "tom/elm_css" == Nothing
fromString "tom/x.js"    == Nothing
fromString "elm"         == Nothing
fromString "html"        == Nothing

JSON Conversions

encode : Name -> Json.Encode.Value

Turn a Name into a string for use in elm.json

decoder : Json.Decode.Decoder Name

Decode the module name strings that appear in elm.json