TSFoster/elm-uuid/1.0.1

NOTE: the latest version is 4.3.1

UUID

A module defining UUIDs in the general, and providing functions for encoding, decoding and formatting UUIDs.

type alias UUID version variant =
UUID version variant

Opaque type to encapsulate UUIDs. Uses phantom types to provide information about version and variant.

type alias Model =
    { title : String
    , uuid : UUID Version4 Variant1
    , published : Maybe Date
    , authors : List (UUID Version4 Variant1)
    }
type alias Version4 =
Version4

Used to denote version of version 4 UUIDs.

type alias Variant1 =
Variant1

Used to denote variation of variation 1 UUIDs.

type alias Variant2 =
Variant2

Used to denote variation of variation 2 UUIDs.

type alias Nil =
Nil

Used to denote version and variant of the nil UUID.

nil : UUID Nil Nil

The nil UUID. This is the special UUID "00000000-0000-0000-0000-000000000000".

JSON

encode : UUID version variant -> Value

Encode a UUID of any version or variant as a JSON string.

Json.Encode.encode 0 (encode 0 nil) == "\"00000000-0000-0000-0000-000000000000\""
decoder : Decoder (UUID version variant)

Decodes a UUID of any version or variant from a JSON string.

"\"123e4567-e89b-12d3-a456-426655440000\""
    |> Json.Decode.decodeString decoder
    |> canonical -- == "123e4567-e89b-12d3-a456-426655440000"

Formatting

canonical : UUID version variant -> String

Convert UUID to canonical textual representation

canonical nil == "00000000-0000-0000-0000-000000000000"
microsoftGUID : UUID version variant -> String

Convert UUID to Microsoft GUID representation

microsoftGUID nil == "{00000000-0000-0000-0000-000000000000}"
urn : UUID version variant -> String

Convert UUID to URN-namespaced representation

urn nil == "urn:uuid:00000000-0000-0000-0000-000000000000"