Copyright | 2013 Kei Hibino |
---|---|
License | BSD3 |
Maintainer | ex8k.hibino@gmail.com |
Stability | experimental |
Portability | unknown |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module defines interfaces between Haskell type and list of SQL type.
- data PersistableSqlType q
- runPersistableNullValue :: PersistableSqlType q -> q
- unsafePersistableSqlTypeFromNull :: q -> PersistableSqlType q
- data PersistableRecordWidth a
- runPersistableRecordWidth :: PersistableRecordWidth a -> Int
- unsafePersistableRecordWidth :: Int -> PersistableRecordWidth a
- unsafeValueWidth :: PersistableRecordWidth a
- (<&>) :: PersistableRecordWidth a -> PersistableRecordWidth b -> PersistableRecordWidth (a, b)
- maybeWidth :: PersistableRecordWidth a -> PersistableRecordWidth (Maybe a)
- data PersistableSqlValue q a
- persistableSqlValue :: PersistableSqlType q -> (q -> a) -> (a -> q) -> PersistableSqlValue q a
- toValue :: PersistableSqlValue q a -> q -> a
- fromValue :: PersistableSqlValue q a -> a -> q
- class Eq q => PersistableType q where
- sqlNullValue :: PersistableType q => q
- class PersistableType q => PersistableValue q a where
- fromSql :: PersistableValue q a => q -> a
- toSql :: PersistableValue q a => a -> q
- class PersistableWidth a where
- derivedWidth :: PersistableWidth a => (PersistableRecordWidth a, Int)
Specify SQL type
data PersistableSqlType q Source
Proof object to specify type q
is SQL type
runPersistableNullValue :: PersistableSqlType q -> q Source
Null value of SQL type q
.
unsafePersistableSqlTypeFromNull Source
:: q | SQL null value of SQL type |
-> PersistableSqlType q | Result proof object |
Unsafely generate PersistableSqlType
proof object from specified SQL null value which type is q
.
Specify record width
data PersistableRecordWidth a Source
Proof object to specify width of Haskell type a
when converting to SQL type list.
runPersistableRecordWidth :: PersistableRecordWidth a -> Int Source
Get width Int
value of record type a
.
unsafePersistableRecordWidth Source
:: Int | Specify width of Haskell type |
-> PersistableRecordWidth a | Result proof object |
Unsafely generate PersistableRecordWidth
proof object from specified width of Haskell type a
.
unsafeValueWidth :: PersistableRecordWidth a Source
Unsafely generate PersistableRecordWidth
proof object for Haskell type a
which is single column type.
(<&>) :: PersistableRecordWidth a -> PersistableRecordWidth b -> PersistableRecordWidth (a, b) Source
Derivation rule of PersistableRecordWidth
for tuple (,) type.
maybeWidth :: PersistableRecordWidth a -> PersistableRecordWidth (Maybe a) Source
Derivation rule of PersistableRecordWidth
from from Haskell type a
into for Haskell type Maybe
a
.
Bidirectional conversion between single column type and SQL type
data PersistableSqlValue q a Source
Proof object to specify value type a
is convertible with SQL type q
persistableSqlValue :: PersistableSqlType q -> (q -> a) -> (a -> q) -> PersistableSqlValue q a Source
Axiom of PersistableSqlValue
for SQL type q
and Haskell type a
.
:: PersistableSqlValue q a | Proof object which has capability to convert |
-> q | SQL type |
-> a | Haskell type |
Run PersistableSqlValue
proof object. Convert from SQL type q
into Haskell type a
.
:: PersistableSqlValue q a | Proof object which has capability to convert |
-> a | Haskell type |
-> q | SQL type |
Run PersistableSqlValue
proof object. Convert from Haskell type a
into SQL type q
.
Inference rules for proof objects
class Eq q => PersistableType q where Source
Interface of inference rule for PersistableSqlType
proof object
sqlNullValue :: PersistableType q => q Source
Inferred Null value of SQL type.
class PersistableType q => PersistableValue q a where Source
Interface of inference rule for PersistableSqlValue
proof object
persistableValue :: PersistableSqlValue q a Source
Infer PersistableSqlValue
proof object.
fromSql :: PersistableValue q a => q -> a Source
Run inferred PersistableSqlValue
proof object. Convert from SQL type q
into Haskell type a
.
toSql :: PersistableValue q a => a -> q Source
Run inferred PersistableSqlValue
proof object. Convert from Haskell type a
into SQL type q
.
class PersistableWidth a where Source
Interface of inference rule for PersistableRecordWidth
proof object
PersistableWidth Bool | |
PersistableWidth Char | |
PersistableWidth Int8 | |
PersistableWidth Int16 | |
PersistableWidth Int32 | |
PersistableWidth Int64 | |
PersistableWidth String | |
PersistableWidth () | Inference rule of |
PersistableWidth a => PersistableWidth (Maybe a) | Inference rule of |
(PersistableWidth a, PersistableWidth b) => PersistableWidth (a, b) | Inference rule of |
derivedWidth :: PersistableWidth a => (PersistableRecordWidth a, Int) Source
Pass type parameter and inferred width value.