mysql-simple-0.4.9: A mid-level MySQL client library.
Copyright(c) 2011 MailRank Inc.
LicenseBSD3
MaintainerPaul Rouse <pyr@doynton.org>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.MySQL.Simple.Result

Description

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 MySQL numeric types that are less accurate than it. For instance, the Haskell Double type is compatible with the MySQL Long type because it can represent a Long exactly. On the other hand, since a Double might lose precision if representing a LongLong, the two are not considered compatible.

Synopsis

Documentation

class FromField a where Source #

A type that can be converted from a ByteString. Any type which is an instance of this class, and is Typeable, can use the default implementation of Result. This provides a method of implementing a decoder for any text-like column, such as TEXT, BLOB, or JSON, instead of implementing Result directly.

The first component of the tuple returned by fromField is a list of acceptable column types, expressed in terms of Type.

Since: 0.4.8

Instances

Instances details
FromField UTCTime Source # 
Instance details

Defined in Database.MySQL.Simple.Result

FromField TimeOfDay Source # 
Instance details

Defined in Database.MySQL.Simple.Result

class Result a where Source #

A type that may be converted from a SQL type.

A default implementation is provided for any type which is an instance of both FromField and Typeable, providing a simple mechanism for user-defined decoding from text- or blob-like fields (including JSON).

Minimal complete definition

Nothing

Methods

convert :: Field -> Maybe ByteString -> a Source #

Convert a SQL value to a Haskell value.

Throws a ResultError if conversion fails.

default convert :: (Typeable a, FromField a) => Field -> Maybe ByteString -> a Source #

Instances

Instances details
Result Int16 Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Int32 Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Int64 Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Int8 Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Word16 Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Word32 Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Word64 Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result ByteString Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result ByteString Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Text Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Text Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Day Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result UTCTime Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result TimeOfDay Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Word8 Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Integer Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Bool Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Double Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Float Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Int Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result Word Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result (Ratio Integer) Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result a => Result (Maybe a) Source # 
Instance details

Defined in Database.MySQL.Simple.Result

Result [Char] Source # 
Instance details

Defined in Database.MySQL.Simple.Result

data ResultError Source #

Exception thrown if conversion from a SQL value to a Haskell value fails.

Constructors

Incompatible

The SQL and Haskell types are not compatible.

UnexpectedNull

A SQL NULL was encountered when the Haskell type did not permit it.

ConversionFailed

The SQL value could not be parsed, or could not be represented as a valid Haskell value, or an unexpected low-level error occurred (e.g. mismatch between metadata and actual data in a row).