diff --git a/DB-record/src/Database/Record/FromSql.hs b/DB-record/src/Database/Record/FromSql.hs index 8912bc05..695bca5c 100644 --- a/DB-record/src/Database/Record/FromSql.hs +++ b/DB-record/src/Database/Record/FromSql.hs @@ -29,7 +29,7 @@ import Database.Record.Persistable Persistable(persistable), PersistableType) import qualified Database.Record.Persistable as Persistable import Database.Record.KeyConstraint - (HasKeyConstraint(constraintKey), KeyConstraint, NotNull, index) + (HasKeyConstraint(keyConstraint), KeyConstraint, NotNull, index) import Control.Monad (liftM, ap) import Control.Applicative ((<$>), Applicative(pure, (<*>))) @@ -90,7 +90,7 @@ instance (FromSql q a, FromSql q b) => FromSql q (a, b) where instance (HasKeyConstraint NotNull a, FromSql q a, PersistableType q) => FromSql q (Maybe a) where - recordFromSql = outer recordFromSql $ constraintKey + recordFromSql = outer recordFromSql $ keyConstraint instance FromSql q () where recordFromSql = recordFromSql' diff --git a/DB-record/src/Database/Record/KeyConstraint.hs b/DB-record/src/Database/Record/KeyConstraint.hs index 1894e14e..41afc72e 100644 --- a/DB-record/src/Database/Record/KeyConstraint.hs +++ b/DB-record/src/Database/Record/KeyConstraint.hs @@ -21,13 +21,13 @@ module Database.Record.KeyConstraint ( unique, notNull, leftKeyConstraint, - HasKeyConstraint (constraintKey), + HasKeyConstraint (keyConstraint), derivedUniqueConstraint, derivedNotNullConstraint ) where -newtype KeyConstraint c a = KeyConstraint { index :: Int } +newtype KeyConstraint c r = KeyConstraint { index :: Int } data Unique data NotNull @@ -37,13 +37,13 @@ type UniqueConstraint = KeyConstraint Unique type NotNullConstraint = KeyConstraint NotNull type PrimaryConstraint = KeyConstraint Primary -specifyKeyConstraint :: Int -> KeyConstraint c a +specifyKeyConstraint :: Int -> KeyConstraint c r specifyKeyConstraint = KeyConstraint -unique :: PrimaryConstraint a -> UniqueConstraint a +unique :: PrimaryConstraint r -> UniqueConstraint r unique = specifyKeyConstraint . index -notNull :: PrimaryConstraint a -> NotNullConstraint a +notNull :: PrimaryConstraint r -> NotNullConstraint r notNull = specifyKeyConstraint . index @@ -51,13 +51,13 @@ leftKeyConstraint :: KeyConstraint k a -> KeyConstraint k (a, b) leftKeyConstraint pa = KeyConstraint (index pa) class HasKeyConstraint c a where - constraintKey :: KeyConstraint c a + keyConstraint :: KeyConstraint c a instance HasKeyConstraint c a => HasKeyConstraint c (a, b) where - constraintKey = leftKeyConstraint constraintKey + keyConstraint = leftKeyConstraint keyConstraint -derivedUniqueConstraint :: HasKeyConstraint Primary a => UniqueConstraint a -derivedUniqueConstraint = unique constraintKey +derivedUniqueConstraint :: HasKeyConstraint Primary r => UniqueConstraint r +derivedUniqueConstraint = unique keyConstraint -derivedNotNullConstraint :: HasKeyConstraint Primary a => NotNullConstraint a -derivedNotNullConstraint = notNull constraintKey +derivedNotNullConstraint :: HasKeyConstraint Primary r => NotNullConstraint r +derivedNotNullConstraint = notNull keyConstraint diff --git a/DB-record/src/Database/Record/TH.hs b/DB-record/src/Database/Record/TH.hs index a63076c1..0f0d9a65 100644 --- a/DB-record/src/Database/Record/TH.hs +++ b/DB-record/src/Database/Record/TH.hs @@ -34,7 +34,7 @@ import Language.Haskell.TH clause, cxt, varStrictType, strictType, isStrict) import Database.Record - (HasKeyConstraint(constraintKey), Primary, NotNull, + (HasKeyConstraint(keyConstraint), Primary, NotNull, Persistable(persistable), PersistableWidth(persistableWidth), fromSql, toSql, FromSql(recordFromSql), recordFromSql', @@ -48,7 +48,7 @@ import Database.Record.Persistable defineHasKeyConstraintInstance :: TypeQ -> TypeQ -> Int -> Q [Dec] defineHasKeyConstraintInstance constraint typeCon index = [d| instance HasKeyConstraint $constraint $typeCon where - constraintKey = specifyKeyConstraint $(integralE index) |] + keyConstraint = specifyKeyConstraint $(integralE index) |] recordTypeNameDefault :: String -> ConName recordTypeNameDefault = conCamelcaseName diff --git a/DB-record/src/Database/Record/ToSql.hs b/DB-record/src/Database/Record/ToSql.hs index 9859e896..3ad4402b 100644 --- a/DB-record/src/Database/Record/ToSql.hs +++ b/DB-record/src/Database/Record/ToSql.hs @@ -27,7 +27,7 @@ module Database.Record.ToSql ( import Database.Record.Persistable (PersistableRecord, Persistable(persistable)) import Database.Record.KeyConstraint - (HasKeyConstraint(constraintKey), KeyConstraint, Primary, Unique, unique, index) + (HasKeyConstraint(keyConstraint), KeyConstraint, Primary, Unique, unique, index) import qualified Database.Record.Persistable as Persistable @@ -75,4 +75,4 @@ updateValuesByUnique = updateValuesByUnique' recordToSql updateValuesByPrimary :: (HasKeyConstraint Primary a, ToSql q a) => a -> [q] -updateValuesByPrimary = updateValuesByUnique (unique constraintKey) +updateValuesByPrimary = updateValuesByUnique (unique keyConstraint)