Created
February 14, 2018 06:01
-
-
Save arowM/3dde727b1c53f9d49953e1c77abd5c84 to your computer and use it in GitHub Desktop.
Handle data type that cannot handle with `Json.Decode.map8`.
This file contains 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 characters
module Sample exposing (..) | |
import Json.Decode exposing (..) | |
type alias ManyFields = | |
{ field1 : Int | |
, field2 : String | |
, field3 : String | |
, field4 : String | |
, field5 : String | |
, field6 : String | |
, field7 : String | |
, field8 : String | |
, field9 : String | |
} | |
manyFields : Decoder ManyFields | |
manyFields = | |
map2 (\( f1, f2, f3, f4, f5 ) ( f6, f7, f8, f9 ) -> ManyFields f1 f2 f3 f4 f5 f6 f7 f8 f9) | |
(map5 (,,,,) | |
(field "field1" int) | |
(field "field2" string) | |
(field "field3" string) | |
(field "field4" string) | |
(field "field5" string) | |
) | |
(map4 (,,,) | |
(field "field6" string) | |
(field "field7" string) | |
(field "field8" string) | |
(field "field9" string) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment