Skip to content

Instantly share code, notes, and snippets.

@arowM
Created February 14, 2018 06:01
Show Gist options
  • Save arowM/3dde727b1c53f9d49953e1c77abd5c84 to your computer and use it in GitHub Desktop.
Save arowM/3dde727b1c53f9d49953e1c77abd5c84 to your computer and use it in GitHub Desktop.
Handle data type that cannot handle with `Json.Decode.map8`.
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