We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e084d8a commit de62fd7Copy full SHA for de62fd7
src/Data/Codec/Argonaut.purs
@@ -148,6 +148,18 @@ type JIndexedCodec a =
148
a a
149
150
-- | A codec for types that are encoded as an array with a specific layout.
151
+-- |
152
+-- | For example, given that we'd like to encode a Person as a 2-element array,
153
+-- | like so `[ "Karl", 25 ]`, we could write the following codec:
154
155
+-- | ```purescript
156
+-- | type Person = { name ∷ String, age ∷ Int }
157
158
+-- | JA.indexedArray "Test Object" $
159
+-- | { name: _, age: _ }
160
+-- | <$> _.name ~ index 0 JA.string
161
+-- | <*> _.age ~ index 1 JA.int
162
+-- | ```
163
indexedArray ∷ ∀ a. String → JIndexedCodec a → JsonCodec a
164
indexedArray name =
165
bihoistGCodec
0 commit comments