Last active
March 8, 2026 06:20
-
-
Save jszmajda/13097b1e5240e43df960090b22be6659 to your computer and use it in GitHub Desktop.
Revisions
-
jszmajda revised this gist
Sep 3, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ type alias User = -- a better way, right? jsonDecoder : JD.Decoder User jsonDecoder = JD.map4 User (JD.field "id" int) (JD.field "email" string) (JD.field "firstName" string) -
jszmajda created this gist
Sep 3, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ -- So I'm decoding JSON with this pattern, but there has to be a better way import Json.Decode as JD type alias User = { id : Int , email : String , firstName : String , lastName : String } -- specifically here: this map4 seems dumb. This function depends on the proper -- ordering of the fields to match the record constructor above. There must be -- a better way, right? jsonDecoder : JD.Decoder User jsonDecoder = JD.map4 (JD.field "id" int) (JD.field "email" string) (JD.field "firstName" string) (JD.field "lastName", string)