Skip to content

Instantly share code, notes, and snippets.

@rippinrobr
Last active July 18, 2018 21:19
Show Gist options
  • Save rippinrobr/4ef27bc5725b90e7981a78722c0fc1bb to your computer and use it in GitHub Desktop.
Save rippinrobr/4ef27bc5725b90e7981a78722c0fc1bb to your computer and use it in GitHub Desktop.
Elm Category type alias and the decode function for a category JSON object
type alias Category = {
id : Int
,name : String
,approved : Int
}
-- categoryDecoder is the code that pulls the data out of the JSON object
-- and creates a Category object
categoryDecoder : Decoder Category
categoryDecoder =
map3 Category
(field "id" int)
(field "name" string)
(field "approved" int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment