Skip to content

Commit 310edbc

Browse files
committed
use ~ in KeyValue instances
1 parent 8b1fe80 commit 310edbc

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ For the latest version of this document, please see [https://github.com/haskell/
33
### 2.1.0.0
44

55
- Change time instances of types with year (`Day`, `UTCTime`) to require years with at least 4 digits.
6+
- Change `KeyValue` instances to be more general (and use equality to constraint them) instead of being more lax flexible instances.
67

78
### 2.0.3.0
89

src/Data/Aeson/Types/ToJSON.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,14 @@ instance KeyValue Series where
334334
name .= value = E.pair name (toEncoding value)
335335
{-# INLINE (.=) #-}
336336

337-
instance KeyValue Pair where
337+
instance (key ~ Key, value ~ Value) => KeyValue (key, value) where
338338
name .= value = (name, toJSON value)
339339
{-# INLINE (.=) #-}
340340

341341
-- | Constructs a singleton 'KM.KeyMap'. For calling functions that
342342
-- demand an 'Object' for constructing objects. To be used in
343343
-- conjunction with 'mconcat'. Prefer to use 'object' where possible.
344-
instance KeyValue Object where
344+
instance value ~ Value => KeyValue (KM.KeyMap value) where
345345
name .= value = KM.singleton name (toJSON value)
346346
{-# INLINE (.=) #-}
347347

0 commit comments

Comments
 (0)