Rename unsafe functions.

This commit is contained in:
Kei Hibino 2013-06-03 00:47:10 +09:00
parent bf986b56d1
commit 6a999edd6a
3 changed files with 13 additions and 13 deletions

View File

@ -16,7 +16,7 @@
-- of table constraint specifiey by keys.
module Database.Record.KeyConstraint (
-- * Constraint specifiey by keys
KeyConstraint, index, specifyKeyConstraint,
KeyConstraint, index, unsafeSpecifyKeyConstraint,
Unique, UniqueConstraint,
NotNull, NotNullConstraint,
@ -31,7 +31,7 @@ module Database.Record.KeyConstraint (
derivedUniqueConstraint,
derivedNotNullConstraint,
specifyNotNullValue
unsafeSpecifyNotNullValue
) where
@ -62,16 +62,16 @@ type NotNullConstraint = KeyConstraint NotNull
type PrimaryConstraint = KeyConstraint Primary
-- | Unsafely generate 'KeyConstraint' proof object using specified key index.
specifyKeyConstraint :: Int -> KeyConstraint c r
specifyKeyConstraint = KeyConstraint
unsafeSpecifyKeyConstraint :: Int -> KeyConstraint c r
unsafeSpecifyKeyConstraint = KeyConstraint
-- | Derivation rule for 'UniqueConstraint'.
unique :: PrimaryConstraint r -> UniqueConstraint r
unique = specifyKeyConstraint . index
unique = unsafeSpecifyKeyConstraint . index
-- | Derivation rule for 'NotNullConstraint'.
notNull :: PrimaryConstraint r -> NotNullConstraint r
notNull = specifyKeyConstraint . index
notNull = unsafeSpecifyKeyConstraint . index
-- | Derivation rule of 'KeyConstraint' for tuple (,) type.
@ -98,5 +98,5 @@ derivedNotNullConstraint = notNull keyConstraint
-- | Unsafely generate 'NotNullConstraint' proof object of single column value.
specifyNotNullValue :: NotNullConstraint a
specifyNotNullValue = specifyKeyConstraint 0
unsafeSpecifyNotNullValue :: NotNullConstraint a
unsafeSpecifyNotNullValue = unsafeSpecifyKeyConstraint 0

View File

@ -56,7 +56,7 @@ import Database.Record
ToSql(recordToSql), recordToSql')
import Database.Record.KeyConstraint
(specifyKeyConstraint, specifyNotNullValue)
(unsafeSpecifyKeyConstraint, unsafeSpecifyNotNullValue)
import Database.Record.Persistable
(persistableRecord, persistableRecordWidth)
import qualified Database.Record.Persistable as Persistable
@ -75,7 +75,7 @@ recordTypeDefault = toTypeCon . recordTypeNameDefault
defineHasKeyConstraintInstance :: TypeQ -> TypeQ -> Int -> Q [Dec]
defineHasKeyConstraintInstance constraint typeCon index =
[d| instance HasKeyConstraint $constraint $typeCon where
keyConstraint = specifyKeyConstraint $(integralE index) |]
keyConstraint = unsafeSpecifyKeyConstraint $(integralE index) |]
-- | Generate template of 'HasKeyConstraint' 'NotNull' instance.
defineHasNotNullKeyInstance :: TypeQ -> Int -> Q [Dec]
@ -302,5 +302,5 @@ deriveNotNullType typeCon =
persistableWidth = Persistable.valueWidth
instance HasKeyConstraint NotNull $typeCon where
keyConstraint = specifyNotNullValue
keyConstraint = unsafeSpecifyNotNullValue
|]

View File

@ -18,7 +18,7 @@ module Database.Relational.Query.Constraint (
import Database.Relational.Query.Pi (Pi, leafIndex)
import Database.Relational.Query.Pi.Unsafe (defineColumn)
import Database.Record.KeyConstraint
(KeyConstraint, specifyKeyConstraint,
(KeyConstraint, unsafeSpecifyKeyConstraint,
Primary, Unique, NotNull)
import qualified Database.Record.KeyConstraint as C
@ -29,7 +29,7 @@ defineConstraintKey :: Int -> Key c r ct
defineConstraintKey = Key
recordConstraint :: Key c r ct -> KeyConstraint c r
recordConstraint = specifyKeyConstraint . index
recordConstraint = unsafeSpecifyKeyConstraint . index
projectionKey :: Key c r ct -> Pi r ct
projectionKey = defineColumn . index