Skip to content

Commit f84e673

Browse files
authored
Merge pull request #36 from garyb/named-prismatic-codec
Add name for 'prismaticCodec'
2 parents 3f6ec25 + 6c94221 commit f84e673

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Data/Codec/Argonaut.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ fix f =
329329
-- |
330330
-- | ```purescript
331331
-- | nonEmptyString ∷ CA.JsonCodec NES.NonEmptyString
332-
-- | nonEmptyString = CA.prismaticCodec NES.fromString NES.toString CA.string
332+
-- | nonEmptyString = CA.prismaticCodec "NonEmptyString" NES.fromString NES.toString CA.string
333333
-- | ```
334334
-- |
335335
-- | Another example might be to handle a mapping from a small sum type to
@@ -339,7 +339,7 @@ fix f =
339339
-- | data Direction = North | South | West | East
340340
-- |
341341
-- | directionCodec :: JsonCodec Direction
342-
-- | directionCodec = prismaticCodec dec enc string
342+
-- | directionCodec = CA.prismaticCodec "Direction" dec enc string
343343
-- | where
344344
-- | dec = case _ of
345345
-- | "N" -> Just North
@@ -357,8 +357,8 @@ fix f =
357357
-- |
358358
-- | Although for this latter case there are some other options too, in the form
359359
-- | of `Data.Codec.Argonaut.Generic.nullarySum` and `Data.Codec.Argonaut.Sum.enumSum`.
360-
prismaticCodec a b. (a Maybe b) (b a) JsonCodec a JsonCodec b
361-
prismaticCodec f g orig =
360+
prismaticCodec a b. String (a Maybe b) (b a) JsonCodec a JsonCodec b
361+
prismaticCodec name f g orig =
362362
basicCodec
363-
(\json' → note (UnexpectedValue json') <<< f =<< decode orig json')
363+
(\json' → note (Named name (UnexpectedValue json')) <<< f =<< decode orig json')
364364
(encode orig <<< g)

0 commit comments

Comments
 (0)