-
Notifications
You must be signed in to change notification settings - Fork 13
/
Types.elm
64 lines (45 loc) · 1.34 KB
/
Types.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module Types exposing (Commit, Language(..), Stargazer, Translations)
import Dict exposing (Dict)
import Iso8601
import Json.Decode exposing (Decoder, at, dict, field, float, int, string, succeed)
import Json.Decode.Pipeline exposing (required, requiredAt)
import Time exposing (Posix)
type Language
= English
| Finnish
| FinnishFormal
type alias Translations =
Dict String String
decodeTranslations : Decoder Translations
decodeTranslations =
dict string
type alias Commit =
{ userName : String
, sha : String
, date : Posix
, message : String
}
decodeCommit : Decoder Commit
decodeCommit =
succeed Commit
|> requiredAt [ "commit", "author", "name" ] string
|> requiredAt [ "sha" ] string
|> requiredAt [ "commit", "author", "date" ] Iso8601.decoder
|> requiredAt [ "commit", "message" ] string
decodeCommitList : Decoder (List Commit)
decodeCommitList =
Json.Decode.list decodeCommit
type alias Stargazer =
{ login : String
, avatarUrl : String
, url : String
}
decodeStargazer : Decoder Stargazer
decodeStargazer =
succeed Stargazer
|> required "login" string
|> required "avatar_url" string
|> required "html_url" string
decodeStargazerList : Decoder (List Stargazer)
decodeStargazerList =
Json.Decode.list decodeStargazer