persistable-record-0.1.0.1: Binding between SQL database values and haskell records.

Copyright2013 Kei Hibino
LicenseBSD3
Maintainerex8k.hibino@gmail.com
Stabilityexperimental
Portabilityunknown
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.Record.KeyConstraint

Contents

Description

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

Synopsis

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

Arguments

:: Int

Key index which specify this constraint

-> ColumnConstraint c r

Result constraint proof object

Unsafely generate ColumnConstraint proof object using specified key index.

data Unique Source

Constraint type. Unique key.

type UniqueColumnConstraint = ColumnConstraint Unique Source

Specialized unique constraint.

type NotNullColumnConstraint = ColumnConstraint NotNull Source

Specialized not-null constraint.

data Primary Source

Constraint type. Primary key.

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

Arguments

:: [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.

unsafeSpecifyNotNullValue :: NotNullColumnConstraint a Source

Unsafely generate NotNullColumnConstraint proof object of single column value.

Inferences

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.

Methods

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.