Copyright | (c) 2011 MailRank Inc. |
---|---|
License | BSD3 |
Maintainer | Paul Rouse <pyr@doynton.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
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.
- class Result a where
- data ResultError
- = Incompatible { }
- | UnexpectedNull { }
- | ConversionFailed { }
Documentation
A type that may be converted from a SQL type.
Minimal complete definition
Methods
convert :: Field -> Maybe ByteString -> a #
Convert a SQL value to a Haskell value.
Throws a ResultError
if conversion fails.
Instances
Result Bool # | |
Result Double # | |
Result Float # | |
Result Int # | |
Result Int8 # | |
Result Int16 # | |
Result Int32 # | |
Result Int64 # | |
Result Integer # | |
Result Word # | |
Result Word8 # | |
Result Word16 # | |
Result Word32 # | |
Result Word64 # | |
Result ByteString # | |
Result ByteString # | |
Result Text # | |
Result Text # | |
Result TimeOfDay # | |
Result UTCTime # | |
Result Day # | |
Result [Char] # | |
Result a => Result (Maybe a) # | |
Result (Ratio Integer) # | |
data ResultError #
Exception thrown if conversion from a SQL value to a Haskell value fails.
Constructors
Incompatible | The SQL and Haskell types are not compatible. |
Fields
| |
UnexpectedNull | A SQL |
Fields
| |
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). |
Fields
|
Instances