Skip to content

Commit 11ee4db

Browse files
committed
Polish after hashable
1 parent cc193f4 commit 11ee4db

40 files changed

+26
-68
lines changed

src/library/PostgresqlTypes/Bit.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ where
1616
import qualified Data.Attoparsec.Text as Attoparsec
1717
import qualified Data.Bits as Bits
1818
import qualified Data.ByteString as ByteString
19-
import Data.Hashable (Hashable (..))
2019
import qualified Data.Text as Text
2120
import qualified Data.Vector.Generic as Vg
2221
import qualified GHC.TypeLits as TypeLits
@@ -40,6 +39,7 @@ newtype Bit (numBits :: TypeLits.Nat)
4039
ByteString
4140
deriving stock (Eq, Ord)
4241
deriving (Show, Read, IsString) via (ViaIsScalar (Bit numBits))
42+
deriving newtype (Hashable)
4343

4444
instance (TypeLits.KnownNat numBits) => Arbitrary (Bit numBits) where
4545
arbitrary = do
@@ -49,9 +49,6 @@ instance (TypeLits.KnownNat numBits) => Arbitrary (Bit numBits) where
4949
Nothing -> error "Arbitrary Bit: Generated bit string has incorrect length"
5050
Just bit -> pure bit
5151

52-
instance Hashable (Bit numBits) where
53-
hashWithSalt salt (Bit bytes) = hashWithSalt salt bytes
54-
5552
instance (TypeLits.KnownNat numBits) => IsScalar (Bit numBits) where
5653
schemaName = Tagged Nothing
5754
typeName = Tagged "bit"

src/library/PostgresqlTypes/Bool.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ where
1111

1212
import qualified Data.Attoparsec.Text as Attoparsec
1313
import qualified Data.Bool
14-
import Data.Hashable (Hashable)
1514
import PostgresqlTypes.Algebra
1615
import PostgresqlTypes.Prelude hiding (Bool)
1716
import PostgresqlTypes.Via

src/library/PostgresqlTypes/Box.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module PostgresqlTypes.Box
1414
where
1515

1616
import qualified Data.Attoparsec.Text as Attoparsec
17-
import Data.Hashable (Hashable (..))
1817
import GHC.Float (castDoubleToWord64, castWord64ToDouble)
1918
import PostgresqlTypes.Algebra
2019
import PostgresqlTypes.Prelude
@@ -58,7 +57,8 @@ instance Arbitrary Box where
5857

5958
instance Hashable Box where
6059
hashWithSalt salt (Box x1 y1 x2 y2) =
61-
salt `hashWithSalt` castDoubleToWord64 x1
60+
salt
61+
`hashWithSalt` castDoubleToWord64 x1
6262
`hashWithSalt` castDoubleToWord64 y1
6363
`hashWithSalt` castDoubleToWord64 x2
6464
`hashWithSalt` castDoubleToWord64 y2

src/library/PostgresqlTypes/Bpchar.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module PostgresqlTypes.Bpchar
1414
where
1515

1616
import qualified Data.Attoparsec.Text as Attoparsec
17-
import Data.Hashable (Hashable (..))
1817
import Data.String
1918
import qualified Data.Text as Text
2019
import qualified Data.Text.Encoding as Text.Encoding
@@ -43,9 +42,10 @@ import qualified TextBuilder
4342
--
4443
-- For example, @char(1)@ in SQL is @Bpchar 1@ in Haskell, while @\"char\"@ in SQL is
4544
-- 'PostgresqlTypes.Char.Char' in Haskell. These are completely different types in PostgreSQL.
46-
data Bpchar (numChars :: TypeLits.Nat) = Bpchar Text
45+
newtype Bpchar (numChars :: TypeLits.Nat) = Bpchar Text
4746
deriving stock (Eq, Ord)
4847
deriving (Show, Read, IsString) via (ViaIsScalar (Bpchar numChars))
48+
deriving newtype (Hashable)
4949

5050
instance (TypeLits.KnownNat numChars) => Arbitrary (Bpchar numChars) where
5151
arbitrary = do
@@ -56,9 +56,6 @@ instance (TypeLits.KnownNat numChars) => Arbitrary (Bpchar numChars) where
5656
Nothing -> error "Arbitrary Bpchar: Generated string has incorrect length"
5757
Just char -> pure char
5858

59-
instance Hashable (Bpchar numChars) where
60-
hashWithSalt salt (Bpchar txt) = hashWithSalt salt txt
61-
6259
instance (TypeLits.KnownNat numChars) => IsScalar (Bpchar numChars) where
6360
schemaName = Tagged Nothing
6461
typeName = Tagged "bpchar"

src/library/PostgresqlTypes/Bytea.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ where
1111

1212
import qualified Data.Attoparsec.Text as Attoparsec
1313
import qualified Data.ByteString as ByteString
14-
import Data.Hashable (Hashable)
1514
import qualified Data.Text as Text
1615
import PostgresqlTypes.Algebra
1716
import PostgresqlTypes.Prelude

src/library/PostgresqlTypes/Char.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ where
1515

1616
import qualified Data.Attoparsec.Text as Attoparsec
1717
import qualified Data.Char
18-
import Data.Hashable (Hashable)
1918
import PostgresqlTypes.Algebra
2019
import PostgresqlTypes.Prelude hiding (Char)
2120
import PostgresqlTypes.Via

src/library/PostgresqlTypes/Cidr.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ where
1616

1717
import qualified Data.Attoparsec.Text as Attoparsec
1818
import Data.Bits
19-
import Data.Hashable (Hashable (..))
2019
import PostgresqlTypes.Algebra
2120
import PostgresqlTypes.Prelude hiding (fold)
2221
import PostgresqlTypes.Via

src/library/PostgresqlTypes/Circle.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module PostgresqlTypes.Circle
1313
where
1414

1515
import qualified Data.Attoparsec.Text as Attoparsec
16-
import Data.Hashable (Hashable (..))
1716
import GHC.Float (castDoubleToWord64, castWord64ToDouble)
1817
import PostgresqlTypes.Algebra
1918
import PostgresqlTypes.Prelude
@@ -54,7 +53,8 @@ instance Arbitrary Circle where
5453

5554
instance Hashable Circle where
5655
hashWithSalt salt (Circle x y r) =
57-
salt `hashWithSalt` castDoubleToWord64 x
56+
salt
57+
`hashWithSalt` castDoubleToWord64 x
5858
`hashWithSalt` castDoubleToWord64 y
5959
`hashWithSalt` castDoubleToWord64 r
6060

src/library/PostgresqlTypes/Date.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module PostgresqlTypes.Date
1111
where
1212

1313
import qualified Data.Attoparsec.Text as Attoparsec
14-
import Data.Hashable (Hashable)
1514
import qualified Data.Time as Time
1615
import PostgresqlTypes.Algebra
1716
import PostgresqlTypes.Prelude

src/library/PostgresqlTypes/Float4.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module PostgresqlTypes.Float4
1010
where
1111

1212
import qualified Data.Attoparsec.Text as Attoparsec
13-
import Data.Hashable (Hashable)
1413
import GHC.Float (castFloatToWord32, castWord32ToFloat)
1514
import PostgresqlTypes.Algebra
1615
import PostgresqlTypes.Prelude

0 commit comments

Comments
 (0)