Skip to content

Commit b9da2f3

Browse files
committed
Return eitherDecodeLenient as deprecated synonym
1 parent d074bba commit b9da2f3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

servant/src/Servant/API/ContentTypes.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ module Servant.API.ContentTypes
6565
, AllMime(..)
6666
, AllMimeRender(..)
6767
, AllMimeUnrender(..)
68+
, eitherDecodeLenient
6869
, canHandleAcceptH
6970
) where
7071

@@ -364,6 +365,12 @@ instance NFData NoContent
364365
--------------------------------------------------------------------------
365366
-- * MimeUnrender Instances
366367

368+
-- | Deprecated: since aeson version 0.9 `eitherDecode` has lenient behavior.
369+
--
370+
eitherDecodeLenient :: FromJSON a => ByteString -> Either String a
371+
eitherDecodeLenient = eitherDecode
372+
{-# DEPRECATED eitherDecodeLenient "use eitherDecode instead" #-}
373+
367374
-- | `eitherDecode`
368375
instance FromJSON a => MimeUnrender JSON a where
369376
mimeUnrender _ = eitherDecode

servant/test/Servant/API/ContentTypesSpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ spec = describe "Servant.API.ContentTypes" $ do
219219
handleCTypeH (Proxy :: Proxy '[JSONorText]) "image/jpeg"
220220
"foobar" `shouldBe` (Nothing :: Maybe (Either String Int))
221221

222-
describe "eitherDecodeLenient" $ do
222+
describe "eitherDecode is lenient" $ do
223223

224224
-- Since servant-0.20.1 MimeUnrender JSON instance uses eitherDecode,
225225
-- as aeson >= 0.9 supports decoding top-level strings and numbers.

0 commit comments

Comments
 (0)