Reduce dependencies to PersistableRecord.

This commit is contained in:
Kei Hibino 2014-07-29 14:46:42 +09:00
parent bcaba84c9e
commit cef1595e7d
2 changed files with 2 additions and 16 deletions

View File

@ -19,8 +19,6 @@ module Database.Record.FromSql (
RecordFromSql, runTakeRecord, runToRecord,
createRecordFromSql,
recordDeSerializer,
(<&>),
maybeRecord,
@ -32,8 +30,7 @@ module Database.Record.FromSql (
) where
import Database.Record.Persistable
(PersistableType, PersistableRecord,
PersistableValue, persistableValue, toValue)
(PersistableType, PersistableValue, persistableValue, toValue)
import qualified Database.Record.Persistable as Persistable
import Database.Record.KeyConstraint
(HasColumnConstraint(columnConstraint), ColumnConstraint, NotNull, index)
@ -85,10 +82,6 @@ createRecordFromSql :: ([q] -> (a, [q])) -- ^ Convert function body
-> RecordFromSql q a -- ^ Result proof object
createRecordFromSql = RecordFromSql
-- | Derive 'RecordFromSql' proof object from 'PersistableRecord'.
recordDeSerializer :: PersistableRecord q a -> RecordFromSql q a
recordDeSerializer = createRecordFromSql . Persistable.takeRecord
-- | Run 'RecordFromSql' proof object. Convert from list of SQL type ['q'] into Haskell type 'a'.
runToRecord :: RecordFromSql q a -- ^ Proof object which has capability to convert
-> [q] -- ^ list of SQL type

View File

@ -18,8 +18,6 @@ module Database.Record.ToSql (
ToSqlM, RecordToSql, runFromRecord,
createRecordToSql,
recordSerializer,
(<&>),
-- * Inference rules of 'RecordToSql' conversion
@ -47,10 +45,9 @@ import qualified Data.DList as DList
import Database.Record.Persistable
(PersistableSqlType, runPersistableNullValue, PersistableType (persistableType),
PersistableRecordWidth, runPersistableRecordWidth, PersistableWidth(persistableWidth),
PersistableRecord, PersistableValue, persistableValue, fromValue)
PersistableValue, persistableValue, fromValue)
import Database.Record.KeyConstraint
(Primary, Unique, KeyConstraint, HasKeyConstraint(keyConstraint), unique, indexes)
import qualified Database.Record.Persistable as Persistable
-- | Context type to convert SQL type list.
@ -80,10 +77,6 @@ createRecordToSql :: (a -> [q]) -- ^ Convert function body
-> RecordToSql q a -- ^ Result proof object
createRecordToSql f = wrapToSql $ tell . DList.fromList . f
-- | Derive 'RecordToSql' proof object from 'PersistableRecord'.
recordSerializer :: PersistableRecord q a -> RecordToSql q a
recordSerializer = createRecordToSql . Persistable.fromRecord
-- | Derivation rule of 'RecordToSql' proof object for Haskell tuple (,) type.
(<&>) :: RecordToSql q a -> RecordToSql q b -> RecordToSql q (a, b)
ra <&> rb = RecordToSql $ \(a, b) -> do