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

Copyright(c) 2012 Leon P Smith
LicenseBSD3
MaintainerLeon P Smith <leon@melding-monads.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

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.

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

Instances

FromField a => FromRow [a] Source 
FromField a => FromRow (Maybe [a]) Source 
(FromField a, FromField b) => FromRow (Maybe (a, b)) Source 
(FromField a, FromField b, FromField c) => FromRow (Maybe (a, b, c)) Source 
(FromField a, FromField b, FromField c, FromField d) => FromRow (Maybe (a, b, c, d)) Source 
(FromField a, FromField b, FromField c, FromField d, FromField e) => FromRow (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 
(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g) => FromRow (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 
(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 
(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 
FromField a => FromRow (Maybe (Vector a)) Source 
FromField a => FromRow (Maybe (Only a)) Source 
FromField a => FromRow (Vector a) Source 
FromField a => FromRow (Only a) Source 
(FromField a, FromField b) => FromRow (a, b) Source 
(FromRow a, FromRow b) => FromRow ((:.) a b) Source 
(FromField a, FromField b, FromField c) => FromRow (a, b, c) Source 
(FromField a, FromField b, FromField c, FromField d) => FromRow (a, b, c, d) Source 
(FromField a, FromField b, FromField c, FromField d, FromField e) => FromRow (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 
(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g) => FromRow (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 
(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 
(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