-
Notifications
You must be signed in to change notification settings - Fork 5
/
Auto.elm
425 lines (291 loc) · 19.9 KB
/
Auto.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
module Foo.Bar.Auto exposing (..)
{- this file is generated by <https://github.com/choonkeat/elm-auto-encoder-decoder> do not modify manually -}
import Foo.Bar exposing (..)
import Dict exposing (Dict)
import Foo.Baz
import Foo.Baz.Auto exposing (..)
import Json.Decode
import Json.Encode
import Main
import Platform
import Set
-- HARDCODE
encodeString : String -> Json.Encode.Value
encodeString =
Json.Encode.string
encodeInt : Int -> Json.Encode.Value
encodeInt =
Json.Encode.int
encodeFloat : Float -> Json.Encode.Value
encodeFloat =
Json.Encode.float
encodeBool : Bool -> Json.Encode.Value
encodeBool =
Json.Encode.bool
encodeList : (a -> Json.Encode.Value) -> List a -> Json.Encode.Value
encodeList =
Json.Encode.list
encodeSetSet : (comparable -> Json.Encode.Value) -> Set.Set comparable -> Json.Encode.Value
encodeSetSet encoder =
Set.toList >> encodeList encoder
encodeDictDict : (a -> Json.Encode.Value) -> (b -> Json.Encode.Value) -> Dict.Dict a b -> Json.Encode.Value
encodeDictDict keyEncoder =
Json.Encode.dict (\k -> Json.Encode.encode 0 (keyEncoder k))
encode_Unit : () -> Json.Encode.Value
encode_Unit value =
Json.Encode.list identity [ encodeString "" ]
encodeJsonDecodeValue : Json.Decode.Value -> Json.Encode.Value
encodeJsonDecodeValue a =
a
encodeJsonEncodeValue : Json.Encode.Value -> Json.Encode.Value
encodeJsonEncodeValue a =
a
--
decodeJsonDecodeValue : Json.Decode.Decoder Json.Decode.Value
decodeJsonDecodeValue =
Json.Decode.value
decodeJsonEncodeValue : Json.Decode.Decoder Json.Decode.Value
decodeJsonEncodeValue =
Json.Decode.value
decodeString : Json.Decode.Decoder String
decodeString =
Json.Decode.string
decodeInt : Json.Decode.Decoder Int
decodeInt =
Json.Decode.int
decodeFloat : Json.Decode.Decoder Float
decodeFloat =
Json.Decode.float
decodeBool : Json.Decode.Decoder Bool
decodeBool =
Json.Decode.bool
decodeList : (Json.Decode.Decoder a) -> Json.Decode.Decoder (List a)
decodeList =
Json.Decode.list
decodeSetSet : (Json.Decode.Decoder comparable) -> Json.Decode.Decoder (Set.Set comparable)
decodeSetSet =
Json.Decode.list >> Json.Decode.map Set.fromList
decodeDictDict : (Json.Decode.Decoder comparable) -> (Json.Decode.Decoder b) -> Json.Decode.Decoder (Dict.Dict comparable b)
decodeDictDict keyDecoder valueDecoder =
Json.Decode.dict valueDecoder
|> Json.Decode.map (\dict ->
Dict.foldl (\string v acc ->
case Json.Decode.decodeString keyDecoder string of
Ok k ->
Dict.insert k v acc
Err _ ->
acc
) Dict.empty dict
)
decode_Unit : Json.Decode.Decoder ()
decode_Unit =
Json.Decode.index 0 Json.Decode.string
|> Json.Decode.andThen
(\word ->
case word of
"" -> (Json.Decode.succeed ())
_ -> Json.Decode.fail ("Unexpected Unit: " ++ word)
)
-- PRELUDE
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Nothing") [],CustomTypeConstructor (TitleCaseDotPhrase "Just") [ConstructorTypeParam "a"]], name = TypeName "Maybe" ["a"] } -}
encodeMaybe : (a -> Json.Encode.Value) -> Maybe a -> Json.Encode.Value
encodeMaybe arga value =
case value of
(Nothing) -> (Json.Encode.list identity [ encodeString "Nothing" ])
(Just m0) -> (Json.Encode.list identity [ encodeString "Just", (arga m0) ])
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Err") [ConstructorTypeParam "x"],CustomTypeConstructor (TitleCaseDotPhrase "Ok") [ConstructorTypeParam "a"]], name = TypeName "Result" ["x","a"] } -}
encodeResult : (x -> Json.Encode.Value) -> (a -> Json.Encode.Value) -> Result x a -> Json.Encode.Value
encodeResult argx arga value =
case value of
(Err m0) -> (Json.Encode.list identity [ encodeString "Err", (argx m0) ])
(Ok m0) -> (Json.Encode.list identity [ encodeString "Ok", (arga m0) ])
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Nothing") [],CustomTypeConstructor (TitleCaseDotPhrase "Just") [ConstructorTypeParam "a"]], name = TypeName "Maybe" ["a"] } -}
decodeMaybe : (Json.Decode.Decoder (a)) -> Json.Decode.Decoder (Maybe a)
decodeMaybe arga =
Json.Decode.index 0 Json.Decode.string
|> Json.Decode.andThen
(\word ->
case word of
"Nothing" -> (Json.Decode.succeed Nothing)
"Just" -> (Json.Decode.succeed Just |> (Json.Decode.map2 (|>) (Json.Decode.index 1 (arga))))
_ -> Json.Decode.fail ("Unexpected Maybe: " ++ word)
)
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Err") [ConstructorTypeParam "x"],CustomTypeConstructor (TitleCaseDotPhrase "Ok") [ConstructorTypeParam "a"]], name = TypeName "Result" ["x","a"] } -}
decodeResult : (Json.Decode.Decoder (x)) -> (Json.Decode.Decoder (a)) -> Json.Decode.Decoder (Result x a)
decodeResult argx arga =
Json.Decode.index 0 Json.Decode.string
|> Json.Decode.andThen
(\word ->
case word of
"Err" -> (Json.Decode.succeed Err |> (Json.Decode.map2 (|>) (Json.Decode.index 1 (argx))))
"Ok" -> (Json.Decode.succeed Ok |> (Json.Decode.map2 (|>) (Json.Decode.index 1 (arga))))
_ -> Json.Decode.fail ("Unexpected Result: " ++ word)
)
{-| TypeAliasDef (AliasCustomType (TypeName "Foo.Bar.Acknowledgement" ["x"]) (CustomTypeConstructor (TitleCaseDotPhrase "Result") [ConstructorTypeParam "x",CustomTypeConstructor (TitleCaseDotPhrase "()") []])) -}
encodeFooBarAcknowledgement : (x -> Json.Encode.Value) -> Foo.Bar.Acknowledgement x -> Json.Encode.Value
encodeFooBarAcknowledgement argx value =
(encodeResult (argx) (encode_Unit)) value
{-| TypeAliasDef (AliasCustomType (TypeName "Foo.Bar.Choice" []) (CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Option") [CustomTypeConstructor (TitleCaseDotPhrase "Bool") []])) -}
encodeFooBarChoice : Foo.Bar.Choice -> Json.Encode.Value
encodeFooBarChoice value =
(encodeFooBarOption (encodeBool)) value
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Traditional_phrase") [],CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Bespoke_sentence") []], name = TypeName "Foo.Bar.Custom_word" [] } -}
encodeFooBarCustom_word : Foo.Bar.Custom_word -> Json.Encode.Value
encodeFooBarCustom_word value =
case value of
(Foo.Bar.Traditional_phrase) -> (Json.Encode.list identity [ encodeString "Foo.Bar.Traditional_phrase" ])
(Foo.Bar.Bespoke_sentence) -> (Json.Encode.list identity [ encodeString "Foo.Bar.Bespoke_sentence" ])
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Hello") [],CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Good") [CustomTypeConstructor (TitleCaseDotPhrase "String") [],CustomTypeConstructor (TitleCaseDotPhrase "Result") [ConstructorTypeParam "x",CustomTypeConstructor (TitleCaseDotPhrase "Maybe") [CustomTypeConstructor (TitleCaseDotPhrase "String") []]]]], name = TypeName "Foo.Bar.Hello" ["x"] } -}
encodeFooBarHello : (x -> Json.Encode.Value) -> Foo.Bar.Hello x -> Json.Encode.Value
encodeFooBarHello argx value =
case value of
(Foo.Bar.Hello) -> (Json.Encode.list identity [ encodeString "Foo.Bar.Hello" ])
(Foo.Bar.Good m0 m1) -> (Json.Encode.list identity [ encodeString "Foo.Bar.Good", (encodeString m0), (encodeResult (argx) (encodeMaybe (encodeString)) m1) ])
{-| TypeAliasDef (AliasCustomType (TypeName "Foo.Bar.Lookup" []) (CustomTypeConstructor (TitleCaseDotPhrase "Dict.Dict") [CustomTypeConstructor (TitleCaseDotPhrase "String") [],CustomTypeConstructor (TitleCaseDotPhrase "Foo.Baz.Record") []])) -}
encodeFooBarLookup : Foo.Bar.Lookup -> Json.Encode.Value
encodeFooBarLookup value =
(encodeDictDict (encodeString) (encodeFooBazRecord)) value
{- functions cannot be encoded/decoded into json
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Noop") [],CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Changes") [Function (CustomTypeConstructor (TitleCaseDotPhrase "String") []) (Function (CustomTypeConstructor (TitleCaseDotPhrase "Int") []) (CustomTypeConstructor (TitleCaseDotPhrase "String") []))]], name = TypeName "Foo.Bar.Msg" [] } -}
encodeFooBarMsg : Foo.Bar.Msg -> Json.Encode.Value
encodeFooBarMsg value =
case value of
(Foo.Bar.Noop) -> (Json.Encode.list identity [ encodeString "Foo.Bar.Noop" ])
(Foo.Bar.Changes m0) -> (Json.Encode.list identity [ encodeString "Foo.Bar.Changes", (<function>) ])
-}
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.None") [],CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Some") [ConstructorTypeParam "a"]], name = TypeName "Foo.Bar.Option" ["a"] } -}
encodeFooBarOption : (a -> Json.Encode.Value) -> Foo.Bar.Option a -> Json.Encode.Value
encodeFooBarOption arga value =
case value of
(Foo.Bar.None) -> (Json.Encode.list identity [ encodeString "Foo.Bar.None" ])
(Foo.Bar.Some m0) -> (Json.Encode.list identity [ encodeString "Foo.Bar.Some", (arga m0) ])
{-| TypeAliasDef (AliasRecordType (TypeName "Foo.Bar.Payload" []) [CustomField (FieldName "title") (CustomTypeConstructor (TitleCaseDotPhrase "String") []),CustomField (FieldName "author_person") (CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Person") []),CustomField (FieldName "comments") (CustomTypeConstructor (TitleCaseDotPhrase "Maybe") [CustomTypeConstructor (TitleCaseDotPhrase "String") []]),CustomField (FieldName "blob") (CustomTypeConstructor (TitleCaseDotPhrase "Json.Encode.Value") []),CustomField (FieldName "blob2") (CustomTypeConstructor (TitleCaseDotPhrase "Json.Decode.Value") []),CustomField (FieldName "custom_word") (CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Custom_word") [])]) -}
encodeFooBarPayload : Foo.Bar.Payload -> Json.Encode.Value
encodeFooBarPayload value =
Json.Encode.object
[ ("title", (encodeString) value.title)
, ("author_person", (encodeFooBarPerson) value.author_person)
, ("comments", (encodeMaybe (encodeString)) value.comments)
, ("blob", (encodeJsonEncodeValue) value.blob)
, ("blob2", (encodeJsonDecodeValue) value.blob2)
, ("custom_word", (encodeFooBarCustom_word) value.custom_word)
]
{-| TypeAliasDef (AliasRecordType (TypeName "Foo.Bar.Person" []) [CustomField (FieldName "name") (CustomTypeConstructor (TitleCaseDotPhrase "String") []),CustomField (FieldName "age") (CustomTypeConstructor (TitleCaseDotPhrase "Int") [])]) -}
encodeFooBarPerson : Foo.Bar.Person -> Json.Encode.Value
encodeFooBarPerson value =
Json.Encode.object
[ ("name", (encodeString) value.name)
, ("age", (encodeInt) value.age)
]
{- we cannot auto generate encoder/decoder for unexposed types
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.PrivateCustom") [CustomTypeConstructor (TitleCaseDotPhrase "Int") []]], name = TypeName "Foo.Bar.PrivateCustom" [] } -}
encodeFooBarPrivateCustom : Foo.Bar.PrivateCustom -> Json.Encode.Value
encodeFooBarPrivateCustom value =
case value of
(Foo.Bar.PrivateCustom m0) -> (Json.Encode.list identity [ encodeString "Foo.Bar.PrivateCustom", (encodeInt m0) ])
-}
{- we cannot auto generate encoder/decoder for unexposed types
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.ProtectedCustom") [CustomTypeConstructor (TitleCaseDotPhrase "Int") []]], name = TypeName "Foo.Bar.ProtectedCustom" [] } -}
encodeFooBarProtectedCustom : Foo.Bar.ProtectedCustom -> Json.Encode.Value
encodeFooBarProtectedCustom value =
case value of
(Foo.Bar.ProtectedCustom m0) -> (Json.Encode.list identity [ encodeString "Foo.Bar.ProtectedCustom", (encodeInt m0) ])
-}
{-| TypeAliasDef (AliasCustomType (TypeName "Foo.Bar.Acknowledgement" ["x"]) (CustomTypeConstructor (TitleCaseDotPhrase "Result") [ConstructorTypeParam "x",CustomTypeConstructor (TitleCaseDotPhrase "()") []])) -}
decodeFooBarAcknowledgement : (Json.Decode.Decoder (x)) -> Json.Decode.Decoder (Foo.Bar.Acknowledgement x)
decodeFooBarAcknowledgement argx =
(decodeResult (argx) (decode_Unit))
{-| TypeAliasDef (AliasCustomType (TypeName "Foo.Bar.Choice" []) (CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Option") [CustomTypeConstructor (TitleCaseDotPhrase "Bool") []])) -}
decodeFooBarChoice : Json.Decode.Decoder (Foo.Bar.Choice)
decodeFooBarChoice =
(decodeFooBarOption (decodeBool))
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Traditional_phrase") [],CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Bespoke_sentence") []], name = TypeName "Foo.Bar.Custom_word" [] } -}
decodeFooBarCustom_word : Json.Decode.Decoder (Foo.Bar.Custom_word)
decodeFooBarCustom_word =
Json.Decode.index 0 Json.Decode.string
|> Json.Decode.andThen
(\word ->
case word of
"Foo.Bar.Traditional_phrase" -> (Json.Decode.succeed Foo.Bar.Traditional_phrase)
"Foo.Bar.Bespoke_sentence" -> (Json.Decode.succeed Foo.Bar.Bespoke_sentence)
_ -> Json.Decode.fail ("Unexpected Foo.Bar.Custom_word: " ++ word)
)
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Hello") [],CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Good") [CustomTypeConstructor (TitleCaseDotPhrase "String") [],CustomTypeConstructor (TitleCaseDotPhrase "Result") [ConstructorTypeParam "x",CustomTypeConstructor (TitleCaseDotPhrase "Maybe") [CustomTypeConstructor (TitleCaseDotPhrase "String") []]]]], name = TypeName "Foo.Bar.Hello" ["x"] } -}
decodeFooBarHello : (Json.Decode.Decoder (x)) -> Json.Decode.Decoder (Foo.Bar.Hello x)
decodeFooBarHello argx =
Json.Decode.index 0 Json.Decode.string
|> Json.Decode.andThen
(\word ->
case word of
"Foo.Bar.Hello" -> (Json.Decode.succeed Foo.Bar.Hello)
"Foo.Bar.Good" -> (Json.Decode.succeed Foo.Bar.Good |> (Json.Decode.map2 (|>) (Json.Decode.index 1 (decodeString))) |> (Json.Decode.map2 (|>) (Json.Decode.index 2 (decodeResult (argx) (decodeMaybe (decodeString))))))
_ -> Json.Decode.fail ("Unexpected Foo.Bar.Hello: " ++ word)
)
{-| TypeAliasDef (AliasCustomType (TypeName "Foo.Bar.Lookup" []) (CustomTypeConstructor (TitleCaseDotPhrase "Dict.Dict") [CustomTypeConstructor (TitleCaseDotPhrase "String") [],CustomTypeConstructor (TitleCaseDotPhrase "Foo.Baz.Record") []])) -}
decodeFooBarLookup : Json.Decode.Decoder (Foo.Bar.Lookup)
decodeFooBarLookup =
(decodeDictDict (decodeString) (decodeFooBazRecord))
{- functions cannot be encoded/decoded into json
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Noop") [],CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Changes") [Function (CustomTypeConstructor (TitleCaseDotPhrase "String") []) (Function (CustomTypeConstructor (TitleCaseDotPhrase "Int") []) (CustomTypeConstructor (TitleCaseDotPhrase "String") []))]], name = TypeName "Foo.Bar.Msg" [] } -}
decodeFooBarMsg : Json.Decode.Decoder (Foo.Bar.Msg)
decodeFooBarMsg =
Json.Decode.index 0 Json.Decode.string
|> Json.Decode.andThen
(\word ->
case word of
"Foo.Bar.Noop" -> (Json.Decode.succeed Foo.Bar.Noop)
"Foo.Bar.Changes" -> (Json.Decode.succeed Foo.Bar.Changes |> (Json.Decode.map2 (|>) (Json.Decode.index 1 (<function>))))
_ -> Json.Decode.fail ("Unexpected Foo.Bar.Msg: " ++ word)
)
-}
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.None") [],CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Some") [ConstructorTypeParam "a"]], name = TypeName "Foo.Bar.Option" ["a"] } -}
decodeFooBarOption : (Json.Decode.Decoder (a)) -> Json.Decode.Decoder (Foo.Bar.Option a)
decodeFooBarOption arga =
Json.Decode.index 0 Json.Decode.string
|> Json.Decode.andThen
(\word ->
case word of
"Foo.Bar.None" -> (Json.Decode.succeed Foo.Bar.None)
"Foo.Bar.Some" -> (Json.Decode.succeed Foo.Bar.Some |> (Json.Decode.map2 (|>) (Json.Decode.index 1 (arga))))
_ -> Json.Decode.fail ("Unexpected Foo.Bar.Option: " ++ word)
)
{-| TypeAliasDef (AliasRecordType (TypeName "Foo.Bar.Payload" []) [CustomField (FieldName "title") (CustomTypeConstructor (TitleCaseDotPhrase "String") []),CustomField (FieldName "author_person") (CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Person") []),CustomField (FieldName "comments") (CustomTypeConstructor (TitleCaseDotPhrase "Maybe") [CustomTypeConstructor (TitleCaseDotPhrase "String") []]),CustomField (FieldName "blob") (CustomTypeConstructor (TitleCaseDotPhrase "Json.Encode.Value") []),CustomField (FieldName "blob2") (CustomTypeConstructor (TitleCaseDotPhrase "Json.Decode.Value") []),CustomField (FieldName "custom_word") (CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.Custom_word") [])]) -}
decodeFooBarPayload : Json.Decode.Decoder (Foo.Bar.Payload)
decodeFooBarPayload =
Json.Decode.succeed Foo.Bar.Payload
|> Json.Decode.map2 (|>) (Json.Decode.at [ "title" ] (decodeString))
|> Json.Decode.map2 (|>) (Json.Decode.at [ "author_person" ] (decodeFooBarPerson))
|> Json.Decode.map2 (|>) (Json.Decode.oneOf [Json.Decode.at [ "comments" ] (decodeMaybe (decodeString)), Json.Decode.succeed Nothing])
|> Json.Decode.map2 (|>) (Json.Decode.at [ "blob" ] (decodeJsonEncodeValue))
|> Json.Decode.map2 (|>) (Json.Decode.at [ "blob2" ] (decodeJsonDecodeValue))
|> Json.Decode.map2 (|>) (Json.Decode.at [ "custom_word" ] (decodeFooBarCustom_word))
{-| TypeAliasDef (AliasRecordType (TypeName "Foo.Bar.Person" []) [CustomField (FieldName "name") (CustomTypeConstructor (TitleCaseDotPhrase "String") []),CustomField (FieldName "age") (CustomTypeConstructor (TitleCaseDotPhrase "Int") [])]) -}
decodeFooBarPerson : Json.Decode.Decoder (Foo.Bar.Person)
decodeFooBarPerson =
Json.Decode.succeed Foo.Bar.Person
|> Json.Decode.map2 (|>) (Json.Decode.at [ "name" ] (decodeString))
|> Json.Decode.map2 (|>) (Json.Decode.at [ "age" ] (decodeInt))
{- we cannot auto generate encoder/decoder for unexposed types
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.PrivateCustom") [CustomTypeConstructor (TitleCaseDotPhrase "Int") []]], name = TypeName "Foo.Bar.PrivateCustom" [] } -}
decodeFooBarPrivateCustom : Json.Decode.Decoder (Foo.Bar.PrivateCustom)
decodeFooBarPrivateCustom =
Json.Decode.index 0 Json.Decode.string
|> Json.Decode.andThen
(\word ->
case word of
"Foo.Bar.PrivateCustom" -> (Json.Decode.succeed Foo.Bar.PrivateCustom |> (Json.Decode.map2 (|>) (Json.Decode.index 1 (decodeInt))))
_ -> Json.Decode.fail ("Unexpected Foo.Bar.PrivateCustom: " ++ word)
)
-}
{- we cannot auto generate encoder/decoder for unexposed types
{-| CustomTypeDef { constructors = [CustomTypeConstructor (TitleCaseDotPhrase "Foo.Bar.ProtectedCustom") [CustomTypeConstructor (TitleCaseDotPhrase "Int") []]], name = TypeName "Foo.Bar.ProtectedCustom" [] } -}
decodeFooBarProtectedCustom : Json.Decode.Decoder (Foo.Bar.ProtectedCustom)
decodeFooBarProtectedCustom =
Json.Decode.index 0 Json.Decode.string
|> Json.Decode.andThen
(\word ->
case word of
"Foo.Bar.ProtectedCustom" -> (Json.Decode.succeed Foo.Bar.ProtectedCustom |> (Json.Decode.map2 (|>) (Json.Decode.index 1 (decodeInt))))
_ -> Json.Decode.fail ("Unexpected Foo.Bar.ProtectedCustom: " ++ word)
)
-}