postgresql-simple-0.7.0.1: Mid-Level PostgreSQL client library

Safe Haskell | None
Language | Haskell2010

Database.PostgreSQL.Simple.Newtypes

Description

Module with newtypes suitable to usage with `DerivingVia` or standalone.

The newtypes are named after packages they wrap.

Synopsis

- newtype Aeson a = Aeson a
- getAeson :: Aeson a -> a

# 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 Source # (<$) :: a -> Aeson b -> Aeson a Source #
Read a => Read (Aeson a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Newtypes Methods readsPrec :: Int -> ReadS (Aeson a) Source # readList :: ReadS [Aeson a] Source # readPrec :: ReadPrec (Aeson a) Source # readListPrec :: ReadPrec [Aeson a] Source #
Show a => Show (Aeson a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Newtypes Methods showsPrec :: Int -> Aeson a -> ShowS Source # show :: Aeson a -> String Source # showList :: [Aeson a] -> ShowS Source #
Eq a => Eq (Aeson a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Newtypes Methods (==) :: Aeson a -> Aeson a -> Bool Source # (/=) :: Aeson a -> Aeson a -> Bool Source #
(FromJSON a, Typeable a) => FromField (Aeson a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Newtypes Methods fromField :: FieldParser (Aeson a) Source #
ToJSON a => ToField (Aeson a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Newtypes Methods toField :: Aeson a -> Action Source #

getAeson :: Aeson a -> a Source #