Files
elm-0.19-workshop/advanced/part4/src/Article/Slug.elm
Richard Feldman 2e0d00f947 Add part4
2018-08-05 08:28:31 -04:00

36 lines
451 B
Elm

module Article.Slug exposing (Slug, decoder, toString, urlParser)
import Json.Decode as Decode exposing (Decoder)
import Url.Parser exposing (Parser)
-- TYPES
type Slug
= Slug String
-- CREATE
urlParser : Parser (Slug -> a) a
urlParser =
Url.Parser.custom "SLUG" (\str -> Just (Slug str))
decoder : Decoder Slug
decoder =
Decode.map Slug Decode.string
-- TRANSFORM
toString : Slug -> String
toString (Slug str) =
str