@@ -10,10 +10,12 @@ Stability: experimental
1010-}
1111{-# LANGUAGE
1212 AllowAmbiguousTypes
13+ , DeriveAnyClass
1314 , DeriveFoldable
1415 , DeriveFunctor
1516 , DeriveGeneric
1617 , DeriveTraversable
18+ , DerivingStrategies
1719 , DefaultSignatures
1820 , FlexibleContexts
1921 , FlexibleInstances
@@ -45,6 +47,7 @@ module Squeal.PostgreSQL.PG
4547 , Enumerated (..)
4648 , VarArray (..)
4749 , FixArray (..)
50+ , Oid (..)
4851 -- * Type families
4952 , LabelsPG
5053 , DimPG
@@ -63,7 +66,7 @@ import Data.Int (Int16, Int32, Int64)
6366import Data.Scientific (Scientific)
6467import Data.Time (Day, DiffTime, LocalTime, TimeOfDay, TimeZone, UTCTime)
6568import Data.Vector (Vector)
66−import Data.Word (Word16, Word32, Word64)
69+import Data.Word (Word32)
6770import Data.UUID.Types (UUID)
6871import GHC.TypeLits
6972import Network.IP.Addr (NetAddr, IP)
@@ -105,11 +108,7 @@ type instance PG Int32 = 'PGint4
105108-- | `PGint8`
106109type instance PG Int64 = 'PGint8
107110-- | `PGint2`
108−type instance PG Word16 = 'PGint2
109−-- | `PGint4`
110−type instance PG Word32 = 'PGint4
111−-- | `PGint8`
112−type instance PG Word64 = 'PGint8
111+type instance PG Oid = 'PGoid
113112-- | `PGnumeric`
114113type instance PG Scientific = 'PGnumeric
115114-- | `PGfloat4`
@@ -303,7 +302,8 @@ withConnection "host=localhost port=5432 dbname=exampledb" $ do
303302True
304303-}
305304newtype Money = Money { cents :: Int64 }
306− deriving (Eq, Ord, Show, Read, GHC.Generic)
305+ deriving stock (Eq, Ord, Show, Read, GHC.Generic)
306+ deriving anyclass (SOP.HasDatatypeInfo, SOP.Generic)
307307-- | `PGmoney`
308308type instance PG Money = 'PGmoney
309309
@@ -311,7 +311,8 @@ type instance PG Money = 'PGmoney
311311type it's applied to should be stored as a `PGjson`.
312312-}
313313newtype Json hask = Json {getJson :: hask}
314− deriving (Eq, Ord, Show, Read, GHC.Generic)
314+ deriving stock (Eq, Ord, Show, Read, GHC.Generic)
315+ deriving anyclass (SOP.HasDatatypeInfo, SOP.Generic)
315316-- | `PGjson`
316317type instance PG (Json hask) = 'PGjson
317318
@@ -319,7 +320,8 @@ type instance PG (Json hask) = 'PGjson
319320type it's applied to should be stored as a `PGjsonb`.
320321-}
321322newtype Jsonb hask = Jsonb {getJsonb :: hask}
322− deriving (Eq, Ord, Show, Read, GHC.Generic)
323+ deriving stock (Eq, Ord, Show, Read, GHC.Generic)
324+ deriving anyclass (SOP.HasDatatypeInfo, SOP.Generic)
323325-- | `PGjsonb`
324326type instance PG (Jsonb hask) = 'PGjsonb
325327
@@ -327,7 +329,8 @@ type instance PG (Jsonb hask) = 'PGjsonb
327329type it's applied to should be stored as a `PGcomposite`.
328330-}
329331newtype Composite record = Composite {getComposite :: record}
330− deriving (Eq, Ord, Show, Read, GHC.Generic)
332+ deriving stock (Eq, Ord, Show, Read, GHC.Generic)
333+ deriving anyclass (SOP.HasDatatypeInfo, SOP.Generic)
331334-- | `PGcomposite` @(@`RowPG` @hask)@
332335type instance PG (Composite hask) = 'PGcomposite (RowPG hask)
333336
@@ -335,7 +338,8 @@ type instance PG (Composite hask) = 'PGcomposite (RowPG hask)
335338type it's applied to should be stored as a `PGenum`.
336339-}
337340newtype Enumerated enum = Enumerated {getEnumerated :: enum}
338− deriving (Eq, Ord, Show, Read, GHC.Generic)
341+ deriving stock (Eq, Ord, Show, Read, GHC.Generic)
342+ deriving anyclass (SOP.HasDatatypeInfo, SOP.Generic)
339343-- | `PGenum` @(@`LabelsPG` @hask)@
340344type instance PG (Enumerated hask) = 'PGenum (LabelsPG hask)
341345
@@ -347,7 +351,8 @@ PG (VarArray (Vector Double)) :: PGType
347351= 'PGvararray ('NotNull 'PGfloat8)
348352-}
349353newtype VarArray arr = VarArray {getVarArray :: arr}
350− deriving (Eq, Ord, Show, Read, GHC.Generic)
354+ deriving stock (Eq, Ord, Show, Read, GHC.Generic)
355+ deriving anyclass (SOP.HasDatatypeInfo, SOP.Generic)
351356-- | `PGvararray` @(@`NullPG` @hask)@
352357type instance PG (VarArray (Vector hask)) = 'PGvararray (NullPG hask)
353358type instance PG (VarArray [hask]) = 'PGvararray (NullPG hask)
@@ -360,6 +365,14 @@ PG (FixArray ((Double, Double), (Double, Double))) :: PGType
360365= 'PGfixarray '[2, 2] ('NotNull 'PGfloat8)
361366-}
362367newtype FixArray arr = FixArray {getFixArray :: arr}
363− deriving (Eq, Ord, Show, Read, GHC.Generic)
368+ deriving stock (Eq, Ord, Show, Read, GHC.Generic)
369+ deriving anyclass (SOP.HasDatatypeInfo, SOP.Generic)
364370-- | `PGfixarray` @(@`DimPG` @hask) (@`FixPG` @hask)@
365371type instance PG (FixArray hask) = 'PGfixarray (DimPG hask) (FixPG hask)
372+
373+{- | Object identifiers (`Oid`s) are used internally by PostgreSQL
374+as primary keys for various system tables.
375+-}
376+newtype Oid = Oid { getOid :: Word32 }
377+ deriving stock (Eq, Ord, Show, Read, GHC.Generic)
378+ deriving anyclass (SOP.HasDatatypeInfo, SOP.Generic)