postgresql-simple-0.7.0.0: Mid-Level PostgreSQL client library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.PostgreSQL.Simple.Newtypes

Description

Module with newtypes suitable to usage with DerivingVia or standalone.

The newtypes are named after packages they wrap.

Synopsis

Documentation

newtype Aeson a Source #

A newtype wrapper with ToField and FromField instances based on ToJSON and FromJSON type classes from aeson.

Example using DerivingVia:

data Foo = Foo Int String
  deriving stock (Eq, Show, Generic)            -- GHC built int
  deriving anyclass (FromJSON, ToJSON)          -- Derived using GHC Generics
  deriving (ToField, FromField) via Aeson Foo   -- DerivingVia

Example using Aeson newtype directly, for more ad-hoc queries

execute conn "INSERT INTO tbl (fld) VALUES (?)" (Only (Aeson x))

Since: 0.6.3

Constructors

Aeson a 

Instances

Instances details
Functor Aeson Source # 
Instance details

Defined in Database.PostgreSQL.Simple.Newtypes

Methods

fmap :: (a -> b) -> Aeson a -> Aeson b #

(<$) :: a -> Aeson b -> Aeson a #

Read a => Read (Aeson a) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.Newtypes

Show a => Show (Aeson a) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.Newtypes

Methods

showsPrec :: Int -> Aeson a -> ShowS #

show :: Aeson a -> String #

showList :: [Aeson a] -> ShowS #

Eq a => Eq (Aeson a) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.Newtypes

Methods

(==) :: Aeson a -> Aeson a -> Bool #

(/=) :: Aeson a -> Aeson a -> Bool #

(FromJSON a, Typeable a) => FromField (Aeson a) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.Newtypes

ToJSON a => ToField (Aeson a) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.Newtypes

Methods

toField :: Aeson a -> Action Source #