postgresql-simple-0.6.5: Mid-Level PostgreSQL client library
Copyright(c) 2012 Leon P Smith
LicenseBSD3
MaintainerLeon P Smith <leon@melding-monads.com>
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.PostgreSQL.Simple.FromRow

Description

The FromRow typeclass, for converting a row of results returned by a SQL query into a more useful Haskell representation.

Predefined instances are provided for tuples containing up to ten elements. The instances for Maybe types return Nothing if all the columns that would have been otherwise consumed are null, otherwise it attempts a regular conversion.

Synopsis

Documentation

class FromRow a where Source #

A collection type that can be converted from a sequence of fields. Instances are provided for tuples up to 10 elements and lists of any length.

Note that instances can be defined outside of postgresql-simple, which is often useful. For example, here's an instance for a user-defined pair:

data User = User { name :: String, fileQuota :: Int }

instance FromRow User where
    fromRow = User <$> field <*> field

The number of calls to field must match the number of fields returned in a single row of the query result. Otherwise, a ConversionFailed exception will be thrown.

You can also derive FromRow for your data type using GHC generics, like this:

{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric  #-}

import GHC.Generics (Generic)
import Database.PostgreSQL.Simple (FromRow)

data User = User { name :: String, fileQuota :: Int }
  deriving (Generic, FromRow)

Note that this only works for product types (e.g. records) and does not support sum types or recursive types.

Note that field evaluates its result to WHNF, so the caveats listed in mysql-simple and very early versions of postgresql-simple no longer apply. Instead, look at the caveats associated with user-defined implementations of fromField.

Minimal complete definition

Nothing

Methods

fromRow :: RowParser a Source #

default fromRow :: (Generic a, GFromRow (Rep a)) => RowParser a Source #

Instances

Instances details
FromField a => FromRow (Only a) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Only a) Source #

FromField a => FromRow (Vector a) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

FromField a => FromRow (Maybe (Only a)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

FromField a => FromRow (Maybe (Vector a)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

(FromField a, FromField b) => FromRow (Maybe (a, b)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b)) Source #

(FromField a, FromField b, FromField c) => FromRow (Maybe (a, b, c)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c)) Source #

(FromField a, FromField b, FromField c, FromField d) => FromRow (Maybe (a, b, c, d)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e) => FromRow (Maybe (a, b, c, d, e)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f) => FromRow (Maybe (a, b, c, d, e, f)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g) => FromRow (Maybe (a, b, c, d, e, f, g)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h) => FromRow (Maybe (a, b, c, d, e, f, g, h)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i) => FromRow (Maybe (a, b, c, d, e, f, g, h, i)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j, k)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j, k)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j, k, l)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j, k, l)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o, FromField p) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o, FromField p, FromField q) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o, FromField p, FromField q, FromField r) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o, FromField p, FromField q, FromField r, FromField s) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s)) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o, FromField p, FromField q, FromField r, FromField s, FromField t) => FromRow (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t)) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t)) Source #

FromField a => FromRow (Maybe [a]) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (Maybe [a]) Source #

FromField a => FromRow [a] Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser [a] Source #

(FromRow a, FromRow b) => FromRow (a :. b) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a :. b) Source #

(FromField a, FromField b) => FromRow (a, b) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b) Source #

(FromField a, FromField b, FromField c) => FromRow (a, b, c) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c) Source #

(FromField a, FromField b, FromField c, FromField d) => FromRow (a, b, c, d) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e) => FromRow (a, b, c, d, e) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f) => FromRow (a, b, c, d, e, f) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g) => FromRow (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h) => FromRow (a, b, c, d, e, f, g, h) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i) => FromRow (a, b, c, d, e, f, g, h, i) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j) => FromRow (a, b, c, d, e, f, g, h, i, j) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k) => FromRow (a, b, c, d, e, f, g, h, i, j, k) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l) => FromRow (a, b, c, d, e, f, g, h, i, j, k, l) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k, l) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m) => FromRow (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k, l, m) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n) => FromRow (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o) => FromRow (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o, FromField p) => FromRow (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o, FromField p, FromField q) => FromRow (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o, FromField p, FromField q, FromField r) => FromRow (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o, FromField p, FromField q, FromField r, FromField s) => FromRow (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) Source #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l, FromField m, FromField n, FromField o, FromField p, FromField q, FromField r, FromField s, FromField t) => FromRow (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) Source # 
Instance details

Defined in Database.PostgreSQL.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) Source #

data RowParser a Source #

Instances

Instances details
Alternative RowParser Source # 
Instance details

Defined in Database.PostgreSQL.Simple.Internal

Methods

empty :: RowParser a #

(<|>) :: RowParser a -> RowParser a -> RowParser a #

some :: RowParser a -> RowParser [a] #

many :: RowParser a -> RowParser [a] #

Applicative RowParser Source # 
Instance details

Defined in Database.PostgreSQL.Simple.Internal

Methods

pure :: a -> RowParser a #

(<*>) :: RowParser (a -> b) -> RowParser a -> RowParser b #

liftA2 :: (a -> b -> c) -> RowParser a -> RowParser b -> RowParser c #

(*>) :: RowParser a -> RowParser b -> RowParser b #

(<*) :: RowParser a -> RowParser b -> RowParser a #

Functor RowParser Source # 
Instance details

Defined in Database.PostgreSQL.Simple.Internal

Methods

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

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

Monad RowParser Source # 
Instance details

Defined in Database.PostgreSQL.Simple.Internal

Methods

(>>=) :: RowParser a -> (a -> RowParser b) -> RowParser b #

(>>) :: RowParser a -> RowParser b -> RowParser b #

return :: a -> RowParser a #