Add part3

This commit is contained in:
Richard Feldman
2018-08-05 07:57:52 -04:00
parent 2163df4cb3
commit 46d8a711d5
37 changed files with 5456 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
module Username exposing (Username, decoder, encode, toHtml, toString, urlParser)
import Html exposing (Html)
import Json.Decode as Decode exposing (Decoder)
import Json.Encode as Encode exposing (Value)
import Url.Parser
-- TYPES
type Username
= Username String
-- CREATE
decoder : Decoder Username
decoder =
Decode.map Username Decode.string
-- TRANSFORM
encode : Username -> Value
encode (Username username) =
Encode.string username
toString : Username -> String
toString (Username username) =
username
urlParser : Url.Parser.Parser (Username -> a) a
urlParser =
Url.Parser.custom "USERNAME" (\str -> Just (Username str))
toHtml : Username -> Html msg
toHtml (Username username) =
Html.text username