Skip to content

Commit 27517f0

Browse files
authored
Merge pull request #1105 from haskell/gnd-key
Use GND to derive Key instances
2 parents 16776c4 + 1a666fe commit 27517f0

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

aeson.cabal

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cabal-version: 2.2
22
name: aeson
3-
version: 2.2.2.0
4-
x-revision: 1
3+
version: 2.2.3.0
54
license: BSD-3-Clause
65
license-file: LICENSE
76
category: Text, Web, JSON
@@ -116,7 +115,7 @@ library
116115
, character-ps ^>=0.1
117116
, data-fix ^>=0.3.2
118117
, dlist ^>=1.0
119-
, hashable ^>=1.4.2.0
118+
, hashable ^>=1.4.6.0
120119
, indexed-traversable ^>=0.1.2
121120
, integer-conversion ^>=0.1
122121
, integer-logarithms ^>=1.0.3.1

cabal.project

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ allow-newer: hermes-json:attoparsec-iso8601
1212

1313
-- packages: https://hackage.haskell.org/package/libperf-0.1/candidate/libperf-0.1.tar.gz
1414
-- packages: https://hackage.haskell.org/package/tasty-perfbench-0.1/candidate/tasty-perfbench-0.1.tar.gz
15+
16+
-- constraints: aeson -ordered-keymap

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
For the latest version of this document, please see [https://github.com/haskell/aeson/blob/master/changelog.md](https://github.com/haskell/aeson/blob/master/changelog.md).
22

3+
### 2.2.3.0
4+
5+
* Support `hashable-1.4.6.0`.
6+
37
### 2.2.2.0
48

59
* Support GHC-8.6.5...9.10.1

src/Data/Aeson/Key.hs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE DeriveDataTypeable #-}
3+
{-# LANGUAGE DerivingStrategies #-}
34
{-# LANGUAGE GADTs #-}
5+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6+
{-# LANGUAGE StandaloneDeriving #-}
47
{-# LANGUAGE TemplateHaskellQuotes #-}
58

69
-- |
@@ -39,7 +42,7 @@ import qualified Language.Haskell.TH.Syntax as TH
3942
import qualified Test.QuickCheck as QC
4043

4144
newtype Key = Key { unKey :: Text }
42-
deriving (Eq, Ord, Typeable, Data)
45+
deriving (Typeable, Data)
4346

4447
fromString :: String -> Key
4548
fromString = Key . T.pack
@@ -58,7 +61,7 @@ toText = unKey
5861
--
5962
-- Using 'coercing' we can make more efficient implementations
6063
-- when 'Key' is backed up by 'Text' without exposing internals.
61-
--
64+
--
6265
coercionToText :: Maybe (Coercion Key Text)
6366
coercionToText = Just Coercion
6467
{-# INLINE coercionToText #-}
@@ -79,13 +82,14 @@ instance Read Key where
7982
readPrec = fromString <$> readPrec
8083

8184
instance Show Key where
82-
showsPrec d (Key k) = showsPrec d k
85+
showsPrec d (Key k) = showsPrec d k
8386

8487
instance Data.String.IsString Key where
8588
fromString = fromString
8689

87-
instance Hashable Key where
88-
hashWithSalt salt (Key k) = hashWithSalt salt k
90+
deriving newtype instance Eq Key
91+
deriving newtype instance Ord Key
92+
deriving newtype instance Hashable Key
8993

9094
instance NFData Key where
9195
rnf (Key k) = rnf k

0 commit comments

Comments
 (0)