diff options
Diffstat (limited to 'src/client/Model/User.elm')
-rw-r--r-- | src/client/Model/User.elm | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/client/Model/User.elm b/src/client/Model/User.elm deleted file mode 100644 index 1412913..0000000 --- a/src/client/Model/User.elm +++ /dev/null @@ -1,44 +0,0 @@ -module Model.User - ( Users - , usersDecoder - , User - , userDecoder - , UserId - , userIdDecoder - , getUserName - ) where - -import Json.Decode as Json exposing ((:=)) -import Dict exposing (Dict) - -type alias Users = Dict UserId User - -type alias UserId = Int - -type alias User = - { name : String - , email : String - } - -usersDecoder : Json.Decoder Users -usersDecoder = Json.map Dict.fromList (Json.list userWithIdDecoder) - -userWithIdDecoder : Json.Decoder (UserId, User) -userWithIdDecoder = - Json.object2 (,) - ("id" := userIdDecoder) - userDecoder - -userDecoder : Json.Decoder User -userDecoder = - Json.object2 User - ("name" := Json.string) - ("email" := Json.string) - -userIdDecoder : Json.Decoder UserId -userIdDecoder = Json.int - -getUserName : Users -> UserId -> Maybe String -getUserName users userId = - Dict.get userId users - |> Maybe.map .name |