driebit / elm-ginger / Ginger.Id

The Ginger resource id. We 'tag' the resource id with type Int using elm-tagged. This helps us to not mix up some other Int with a resource id by accident.

The only way to construct a ResourceId is by decoding one from some json or parsing it out of an url path. This is rather strict and there might be some times you just need to create a random ResourceId for whatever reason, this hasn't come up so far, but file an issue if it does.

Definition


type alias ResourceId =
Tagged Resource Basics.Int

Convert

toInt : ResourceId -> Basics.Int

toString : ResourceId -> String

Decode and Encode

fromUrl : Url.Parser.Parser (ResourceId -> a) a

fromJson : Json.Decode.Decoder ResourceId

toJson : ResourceId -> Json.Encode.Value