36 lines
483 B
Elm
36 lines
483 B
Elm
module Todo.UUID exposing (UUID, decoder, toString, urlParser)
|
|
|
|
import Json.Decode as Decode exposing (Decoder)
|
|
import Url.Parser exposing (Parser)
|
|
|
|
|
|
|
|
-- TYPES
|
|
|
|
|
|
type UUID
|
|
= UUID String
|
|
|
|
|
|
|
|
-- CREATE
|
|
|
|
|
|
urlParser : Parser (UUID -> a) a
|
|
urlParser =
|
|
Url.Parser.custom "UUID" (\str -> Just (UUID str))
|
|
|
|
|
|
decoder : Decoder UUID
|
|
decoder =
|
|
Decode.map UUID Decode.string
|
|
|
|
|
|
|
|
-- TRANSFORM
|
|
|
|
|
|
toString : UUID -> String
|
|
toString (UUID str) =
|
|
str
|