{-|
 'mkTableDefinition' converts a 'TableParams' to 'TableDefinition'. Usually
 this is used directly on a record literal of the 'TableParams'. For
 example:

 @
  data Foo key = Foo key { fooId :: Record }
  myTable :: TableDefinition Foo
  myTable = mkTableDefinition $
    TableParams
      { tblName = "foo"
      , tblMapper = User <$> attrField fooId idField
      , tableSafeToDelete = []
      , tblSetKey = \key foo -> foo { fooId = key }
      , tblGetKey = fooId
      , tblComments = []
      }

 @
 -}
mkTableDefinition ::
     TableParams readEntity writeEntity key
  -> TableDefinition readEntity writeEntity key
mkTableDefinition (TableParams {..}) =
  TableDefinition
    { tableFields = fields tblMapper
    , tableFromSql = mkFromSql tblPrimaryKey tblMapper
    , tableToSql = mkToSql tblMapper
    , tablePrimaryKey = tblPrimaryKey
    , tableName = tblName
    , tableSafeToDelete = tblSafeToDelete
    , tableGetKey = tblGetKey
    , tableComments = tblComments
    }
mkTableDefinition ::
     TableParams readEntity writeEntity key
  -> TableDefinition readEntity writeEntity key
mkTableDefinition (TableParams {..}) =
  TableDefinition
    { tableFields = fields tblMapper
    , tableFromSql = mkFromSql tblPrimaryKey tblMapper
    , tableToSql = mkToSql tblMapper
    , tablePrimaryKey = tblPrimaryKey
    , tableName = tblName
    , tableSafeToDelete = tblSafeToDelete
    , tableGetKey = tblGetKey
    , tableComments = tblComments
    }
mkTableDefinition (TableParams {..}) =
  TableDefinition
    { tableFields = fields tblMapper
    , tableFromSql = mkFromSql tblPrimaryKey tblMapper
    , tableToSql = mkToSql tblMapper
    , tablePrimaryKey = tblPrimaryKey
    , tableName = tblName
    , tableSafeToDelete = tblSafeToDelete
    , tableGetKey = tblGetKey
    , tableComments = tblComments
    }