Portability  portable 

Stability  experimental 
Maintainer  Leon P Smith <leon@meldingmonads.com> 
Safe Haskell  SafeInfered 
The Result
typeclass, for converting a single value in a row
returned by a SQL query into a more useful Haskell representation.
A Haskell numeric type is considered to be compatible with all
PostgreSQL numeric types that are less accurate than it. For instance,
the Haskell Double
type is compatible with the PostgreSQL's 32bit
Int
type because it can represent a Int
exactly. On the other hand,
since a Double
might lose precision if representing a 64bit BigInt
,
the two are not considered compatible.
 class Result a where
 convert :: Field > Maybe ByteString > Either SomeException a
 data ResultError
 = Incompatible { }
  UnexpectedNull { }
  ConversionFailed { }
 returnError :: forall a err. (Typeable a, Exception err) => (String > String > String > err) > Field > String > Either SomeException a
Documentation
A type that may be converted from a SQL type.
convert :: Field > Maybe ByteString > Either SomeException aSource
Convert a SQL value to a Haskell value.
Returns an exception if the conversion fails. In the case of
library instances, this will usually be a ResultError
, but may
be a UnicodeException
.
Result Bool  
Result Double  
Result Float  
Result Int  
Result Int16  
Result Int32  
Result Int64  
Result Integer  
Result ByteString  
Result Text  
Result Text  
Result ByteString  
Result Oid  
Result TimeOfDay  
Result UTCTime  
Result Day  
Result Null  
Result RawResult  
Result [Char]  
Result (Ratio Integer)  
Result a => Result (Maybe a)  
Result (Binary ByteString)  
Result (Binary ByteString)  
(Result a, Result b) => Result (Either a b) 
data ResultError Source
Exception thrown if conversion from a SQL value to a Haskell value fails.
Incompatible  The SQL and Haskell types are not compatible. 
 
UnexpectedNull  A SQL 
 
ConversionFailed  The SQL value could not be parsed, or could not be represented as a valid Haskell value, or an unexpected lowlevel error occurred (e.g. mismatch between metadata and actual data in a row). 

returnError :: forall a err. (Typeable a, Exception err) => (String > String > String > err) > Field > String > Either SomeException aSource
Given one of the constructors from ResultError
, the field,
and an errMessage
, this fills in the other fields in the
exception value and returns it in a 'Left . SomeException'
constructor.