Copyright | 2013-2017 Kei Hibino |
---|---|
License | BSD3 |
Maintainer | ex8k.hibino@gmail.com |
Stability | experimental |
Portability | unknown |
Safe Haskell | None |
Language | Haskell2010 |
Database.Record.Persistable
Contents
Description
This module defines proposition interfaces for database value type and record type width.
- data PersistableSqlType q
- runPersistableNullValue :: PersistableSqlType q -> q
- unsafePersistableSqlTypeFromNull :: q -> PersistableSqlType q
- type PersistableRecordWidth a = ProductConst (Sum Int) 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)
- class Eq q => PersistableType q where
- sqlNullValue :: PersistableType q => q
- class PersistableWidth a where
- derivedWidth :: PersistableWidth a => (PersistableRecordWidth a, Int)
- class GFieldWidthList f
- data ProductConst a b
- getProductConst :: ProductConst a b -> a
- genericFieldOffsets :: (Generic a, GFieldWidthList (Rep a)) => ProductConst (Array Int Int) a
Specify database value type
data PersistableSqlType q #
Proposition to specify type q
is database value type, contains null value
runPersistableNullValue :: PersistableSqlType q -> q #
Null value of database value type q
.
unsafePersistableSqlTypeFromNull #
Arguments
:: q | null value of database value type |
-> PersistableSqlType q | Result proof object |
Unsafely specify PersistableSqlType
axiom from specified database null value which type is q
.
Specify record width
type PersistableRecordWidth a = ProductConst (Sum Int) a #
Proposition to specify width of Haskell type a
.
The width is length of database value list which is converted from Haskell type a
.
runPersistableRecordWidth :: PersistableRecordWidth a -> Int #
Get width Int
value of record type a
.
unsafePersistableRecordWidth #
Arguments
:: Int | Specify width of Haskell type |
-> PersistableRecordWidth a | Result proof object |
Unsafely specify PersistableRecordWidth
axiom from specified width of Haskell type a
.
unsafeValueWidth :: PersistableRecordWidth a #
Unsafely specify PersistableRecordWidth
axiom for Haskell type a
which is single column type.
(<&>) :: PersistableRecordWidth a -> PersistableRecordWidth b -> PersistableRecordWidth (a, b) #
Derivation rule of PersistableRecordWidth
for tuple (,) type.
maybeWidth :: PersistableRecordWidth a -> PersistableRecordWidth (Maybe a) #
Derivation rule of PersistableRecordWidth
from from Haskell type a
into for Haskell type Maybe
a
.
Implicit derivation rules, database value type and record type width
class Eq q => PersistableType q where #
Interface of derivation rule for PersistableSqlType
.
Minimal complete definition
Methods
sqlNullValue :: PersistableType q => q #
Implicitly derived null value of database value type.
class PersistableWidth a where #
PersistableWidth
a
is implicit rule to derive PersistableRecordWidth
a
width proposition for type a
.
Generic programming (https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#generic-programming)
with default signature is available for PersistableWidth
class,
so you can make instance like below:
{-# LANGUAGE DeriveGeneric #-} import GHC.Generics (Generic) -- data Foo = Foo { ... } deriving Generic instance PersistableWidth Foo
Methods
persistableWidth :: PersistableRecordWidth a #
persistableWidth :: (Generic a, GFieldWidthList (Rep a)) => PersistableRecordWidth a #
Instances
PersistableWidth () # | Inference rule of |
PersistableWidth a => PersistableWidth (Maybe a) # | Inference rule of |
derivedWidth :: PersistableWidth a => (PersistableRecordWidth a, Int) #
Pass type parameter and inferred width value.
low-level interfaces
class GFieldWidthList f #
Generic width value list of record fields.
Minimal complete definition
gFieldWidthList
Instances
GFieldWidthList U1 # | |
PersistableWidth a => GFieldWidthList (K1 i a) # | |
(GFieldWidthList a, GFieldWidthList b) => GFieldWidthList ((:*:) a b) # | |
GFieldWidthList a => GFieldWidthList (M1 i c a) # | |
data ProductConst a b #
Restricted in product isomorphism record type b
Instances
Show a => Show (ProductConst a b) # | |
getProductConst :: ProductConst a b -> a #
extract constant value of ProductConst
.
genericFieldOffsets :: (Generic a, GFieldWidthList (Rep a)) => ProductConst (Array Int Int) a #
Generic offset array of record fields.