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

Copyright(c) 2012 Leon P Smith
LicenseBSD3
MaintainerLeon P Smith <leon@melding-monads.com>
Stabilityexperimental
Safe HaskellNone
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.

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.

Methods

fromRow :: RowParser a Source #

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

Instances

FromField a => FromRow [a] Source # 

Methods

fromRow :: RowParser [a] Source #

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

Methods

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

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

Methods

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

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

Methods

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

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

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 # 

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 # 

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 # 

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 # 

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 # 

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 # 

Methods

fromRow :: RowParser (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 # 

Methods

fromRow :: RowParser (Only a) Source #

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

Methods

fromRow :: RowParser (a, b) Source #

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

Methods

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

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

Methods

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

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

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 # 

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 # 

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 # 

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 # 

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 # 

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 # 

Methods

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

data RowParser a Source #

Instances

Monad RowParser Source # 

Methods

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

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

return :: a -> RowParser a #

fail :: String -> RowParser a #

Functor RowParser Source # 

Methods

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

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

Applicative RowParser Source # 

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 #

Alternative RowParser Source # 

Methods

empty :: RowParser a #

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

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

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