Skip to content

Commit 475058c

Browse files
authored
Merge pull request #573 from Lysxia/incoherent-tojson
Add INCOHERENT pragma to RecordToPair
2 parents d34cede + 368dcf2 commit 475058c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Data/Aeson/Types/ToJSON.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#endif
2121

2222
#include "overlapping-compat.h"
23+
#include "incoherent-compat.h"
2324

2425
-- TODO: Drop this when we remove support for Data.Attoparsec.Number
2526
{-# OPTIONS_GHC -fno-warn-deprecations #-}
@@ -1009,7 +1010,7 @@ instance ( Selector s
10091010
recordToPairs = fieldToPair
10101011
{-# INLINE recordToPairs #-}
10111012

1012-
instance OVERLAPPING_
1013+
instance INCOHERENT_
10131014
( Selector s
10141015
, GToJSON enc arity (K1 i (Maybe a))
10151016
, GKeyValue enc pairs

tests/Encoders.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ incoherentInstancesNeededParseJSONString :: FromJSON a => Value -> Parser (Incoh
252252
incoherentInstancesNeededParseJSONString = case () of
253253
_ | True -> $(mkParseJSON defaultOptions ''IncoherentInstancesNeeded)
254254
| False -> genericParseJSON defaultOptions
255+
256+
incoherentInstancesNeededToJSON :: ToJSON a => IncoherentInstancesNeeded a -> Value
257+
incoherentInstancesNeededToJSON = case () of
258+
_ | True -> $(mkToJSON defaultOptions ''IncoherentInstancesNeeded)
259+
| False -> genericToJSON defaultOptions
255260
#endif
256261

257262
-------------------------------------------------------------------------------

0 commit comments

Comments
 (0)