Copyright | 2013 Kei Hibino |
---|---|

License | BSD3 |

Maintainer | ex8k.hibino@gmail.com |

Stability | experimental |

Portability | unknown |

Safe Haskell | Safe |

Language | Haskell2010 |

This module provides proof object definitions of table constraint specifiey by keys.

- data ColumnConstraint c r
- index :: ColumnConstraint c r -> Int
- unsafeSpecifyColumnConstraint :: Int -> ColumnConstraint c r
- data Unique
- type UniqueColumnConstraint = ColumnConstraint Unique
- data NotNull
- type NotNullColumnConstraint = ColumnConstraint NotNull
- data Primary
- type PrimaryColumnConstraint = ColumnConstraint Primary
- data KeyConstraint c r
- indexes :: KeyConstraint c r -> [Int]
- unsafeSpecifyKeyConstraint :: [Int] -> KeyConstraint c r
- type UniqueConstraint = KeyConstraint Unique
- type PrimaryConstraint = KeyConstraint Primary
- uniqueColumn :: PrimaryColumnConstraint r -> UniqueColumnConstraint r
- notNullColumn :: PrimaryColumnConstraint r -> NotNullColumnConstraint r
- leftColumnConstraint :: ColumnConstraint NotNull a -> ColumnConstraint NotNull (a, b)
- unsafeSpecifyNotNullValue :: NotNullColumnConstraint a
- deriveComposite :: ColumnConstraint c r -> KeyConstraint c r
- unique :: PrimaryConstraint r -> UniqueConstraint r
- class HasColumnConstraint c a where
- derivedUniqueColumnConstraint :: HasColumnConstraint Primary r => UniqueColumnConstraint r
- derivedNotNullColumnConstraint :: HasColumnConstraint Primary r => NotNullColumnConstraint r
- class HasKeyConstraint c a where
- derivedCompositePrimary :: HasColumnConstraint Primary r => PrimaryConstraint r
- derivedUniqueConstraint :: HasKeyConstraint Primary r => UniqueConstraint r

# Constraint specified by keys

data ColumnConstraint c r Source #

Proof object to specify table constraint
for table record type `r`

and constraint `c`

specified by a single column.

index :: ColumnConstraint c r -> Int Source #

Index of key which specifies table constraint.

unsafeSpecifyColumnConstraint Source #

:: Int | Key index which specify this constraint |

-> ColumnConstraint c r | Result constraint proof object |

Unsafely generate `ColumnConstraint`

proof object using specified key index.

type UniqueColumnConstraint = ColumnConstraint Unique Source #

Specialized unique constraint.

Constraint type. Not-null key.

HasColumnConstraint NotNull a => HasColumnConstraint NotNull (a, b) Source # | Inference rule of |

type NotNullColumnConstraint = ColumnConstraint NotNull Source #

Specialized not-null constraint.

type PrimaryColumnConstraint = ColumnConstraint Primary Source #

Specialized primary constraint.

data KeyConstraint c r Source #

Proof object to specify table constraint
for table record type `r`

and constraint `c`

.
Constraint is specified by composite key.

indexes :: KeyConstraint c r -> [Int] Source #

Index of key which specifies table constraint.

unsafeSpecifyKeyConstraint Source #

:: [Int] | Key index which specify this constraint |

-> KeyConstraint c r | Result constraint proof object |

Unsafely generate `KeyConstraint`

proof object using specified key indexes.

type UniqueConstraint = KeyConstraint Unique Source #

Specialized unique constraint.

type PrimaryConstraint = KeyConstraint Primary Source #

Specialized primary constraint.

# Deriviations

uniqueColumn :: PrimaryColumnConstraint r -> UniqueColumnConstraint r Source #

Derivation rule for `UniqueColumnConstraint`

. Derive Unique from Primary.

notNullColumn :: PrimaryColumnConstraint r -> NotNullColumnConstraint r Source #

Derivation rule for `NotNullColumnConstraint`

. Derive NotNull from Primary.

leftColumnConstraint :: ColumnConstraint NotNull a -> ColumnConstraint NotNull (a, b) Source #

Derivation rule of `ColumnConstraint`

`NotNull`

for tuple (,) type.

unsafeSpecifyNotNullValue :: NotNullColumnConstraint a Source #

Unsafely generate `NotNullColumnConstraint`

proof object of single column value.

deriveComposite :: ColumnConstraint c r -> KeyConstraint c r Source #

Derivation rule for `KeyConstraint`

. Derive from `ColumnConstraint`

.

unique :: PrimaryConstraint r -> UniqueConstraint r Source #

Derivation rule for `UniqueConstraint`

.

# Inferences

class HasColumnConstraint c a where Source #

Interface of inference rule for `ColumnConstraint`

proof object.

columnConstraint :: ColumnConstraint c a Source #

Infer `ColumnConstraint`

proof object.

HasColumnConstraint NotNull a => HasColumnConstraint NotNull (a, b) Source # | Inference rule of |

derivedUniqueColumnConstraint :: HasColumnConstraint Primary r => UniqueColumnConstraint r Source #

Inferred `UniqueColumnConstraint`

proof object.
Record type `r`

has unique key which is derived `r`

has primary key.

derivedNotNullColumnConstraint :: HasColumnConstraint Primary r => NotNullColumnConstraint r Source #

Inferred `NotNullColumnConstraint`

proof object.
Record type `r`

has not-null key which is derived `r`

has primary key.

class HasKeyConstraint c a where Source #

Interface of inference rule for `KeyConstraint`

proof object.

keyConstraint :: KeyConstraint c a Source #

Infer `ColumnConstraint`

proof object.

derivedCompositePrimary :: HasColumnConstraint Primary r => PrimaryConstraint r Source #

Inferred `PrimaryConstraint`

proof object.
Record type `r`

has composite primary key which is derived `r`

has single column primary key.

derivedUniqueConstraint :: HasKeyConstraint Primary r => UniqueConstraint r Source #

Inferred `UniqueConstraint`

proof object.
Record type `r`

has unique key which is derived `r`

has primary key.