h)(G&t      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLM0.3.0.1 Safe-InferredBgeneric-persistence/An enumeration of the supported database types.generic-persistenceThis module defines a wrapper around an HDBC IConnection. Using this wrapper 2 simplifies the signature of the functions in the  module. It allows to use any HDBC connection without having to define a new function for each connection type. It also provides additional attributes to the connection, like the database type and the implicit commit flag. These attributes can be used to implement database specific functionality, modify transaction behaviour, etc.This code has been inspired by the HDBC ConnectionWrapper and some parts have been copied from the HDBC Database.HDBC.Types module.%A wrapper around an HDBC IConnection.generic-persistenceThe database type generic-persistenceIf True, the GenericPersistence functions will commit the transaction after each operation. generic-persistenceThe wrapped connection generic-persistence&a smart constructor for the Conn type.Ngeneric-persistence.allows to execute a function that requires an O argument on a . generic-persistencemanually implement the IConnection type class for the Conn type.     Safe-Inferreddgeneric-persistenceA data type holding meta-data about a type. The Phantom type parameter a ensures type safety for reflective functions that use this type to create type instances.generic-persistencethis function is a smart constructor for TypeInfo objects. It takes a value of type a and returns a `TypeInfo a` object. If the type has no named fields, an error is thrown. If the type has more than one constructor, an error is thrown.   Safe-Inferred1<t %generic-persistenceThe EntityId is a tuple of the constructor name and the primary key value of an Entity.&generic-persistenceThis is the Entity class. It is a type class that is used to define the mapping between a Haskell product type in record notation and a database table. The class has a default implementation for all methods. The default implementation uses the type information to determine a simple 1:1 mapping.That means that - the type name is used as the table name and the - field names are used as the column names. - A field named ' lowercasetypeName%ID' is used as the primary key field.The default implementation can be overridden by defining a custom instance for a type.Please note the following constraints, which apply to all valid Entity type, but that are not explicitely encoded in the type class definition:3The type must be a product type in record notation.+The type must have exactly one constructor.There must be single primary key field, compund primary keys are not supported.'generic-persistence+Converts a database row to a value of type a.(generic-persistenceConverts a value of type a to a database row.)generic-persistence5Returns the name of the primary key field for a type a.*generic-persistenceReturns a list of tuples that map field names to column names for a type a.+generic-persistence)Returns the name of the table for a type a.,generic-persistenceA convenience function: returns the name of the column for a field of a type a..generic-persistence3Returns a string representation of a value of type a.6generic-persistenceThis instance is the most interesting one. It splits the list of Ps into two parts, one for the first field and one for the rest. Then it uses the " instance for the first field to convert the first part of the list and the " instance for the rest of the fields to convert the second part of the list. Finally, it combines the two results using the Q constructor. https://stackoverflow.com/questions/75485429/how-to-use-ghc-generics-to-convert-from-product-data-types-to-a-list-of-sqlvalue/75485650#75485650&'()*+,.%#$"- &'()*+,.%$#"-  Safe-Inferred7generic-persistenceThis module defines some basic SQL statements for Record Data Types that are instances of &. The SQL statements are generated using Haskell generics to provide compile time reflection capabilities.A function that returns an SQL insert statement for an entity. Type a must be an instance of Data. The function will use the field names of the data type to generate the column names in the insert statement. The values of the fields will be used as the values in the insert statement. Output example: INSERT INTO Person (id, name, age, address) VALUES (123456, Alice, 25, "123 Main St");8generic-persistenceA function that returns an SQL update statement for an entity. Type a must be an instance of Entity.9generic-persistenceA function that returns an SQL select statement for entity type a with primary key R.Sgeneric-persistenceA function that returns the column type for a field of an entity. TODO: Support other databases than just SQLite.789<:;=>789<:;=> Safe-Inferred%r?generic-persistenceThis module defines RDBMS Persistence operations for Record Data Types that are instances of Data1. I call instances of such a data type Entities.The Persistence operations are using Haskell generics to provide compile time reflection capabilities. HDBC is used to access the RDBMS.A function that retrieves an entity from a database. The function takes entity id as parameter. If an entity with the given id exists in the database, it is returned as a Just value. If no such entity exists, Nothing is returned. An error is thrown if there are more than one entity with the given id.@generic-persistence-This function retrieves all entities of type a from a database. The function takes an HDBC connection as parameter. The type a3 is determined by the context of the function call.Ageneric-persistence-This function retrieves all entities of type a where a given field has a given value. The function takes an HDBC connection, the name of the field and the value as parameters. The type a is determined by the context of the function call. The function returns a (possibly empty) list of all matching entities.Bgeneric-persistenceThis function converts a list of database rows, represented as a `[[SqlValue]]` to a list of entities. The function takes an HDBC connection and a list of database rows as parameters. The type a is determined by the context of the function call. The function returns a (possibly empty) list of all matching entities. The function is used internally by @ and A. But it can also be used to convert the result of a custom SQL query to a list of entities.Cgeneric-persistenceA function that persists an entity to a database. The function takes an HDBC connection and an entity as parameters. The entity is either inserted or updated, depending on whether it already exists in the database. The required SQL statements are generated dynamically using Haskell generics and reflectionDgeneric-persistence>A function that explicitely inserts an entity into a database.Egeneric-persistenceA function that inserts a list of entities into a database. The function takes an HDBC connection and a list of entities as parameters. The insert-statement is compiled only once and then executed for each entity.Fgeneric-persistence?@ABCDEFGHIJKLMNOPQRSTUVWXYZX[\]^_]`abc d e f g h i j k#generic-persistence-0.3.0.1-inplaceDatabase.GP.ConnDatabase.GP.TypeInfoDatabase.GP.EntityDatabase.GP.SqlGeneratorDatabase.GP.GenericPersistencegeneric-persistenceDatabaseGP Database.GPPaths_generic_persistencePostgresMySQLSQLiteOracleMSSQLConndbimplicitCommit connectionconnect$fIConnectionConn$fShowDatabase $fEqDatabase$fEnumDatabase HasSelectors selectorsHasConstructorgenericConstrNameTypeInfoconstructorName fieldNames fieldTypestypeInfo$fHasConstructorM1$fHasConstructor:+:$fHasConstructorM10$fHasSelectorsFUNU1$fHasSelectorsFUN:*:$fHasSelectorsFUNM1$fHasSelectorsFUNM10$fHasSelectorsFUNM11$fShowTypeInfoGFromRowGToRowgtoRowEntityIdEntityfromRowtoRowidFieldfieldsToColumns tableName columnNameFormaybeFieldTypeFortoString $fGToRowkM1 $fGToRowk:*: $fGToRowkK1 $fGToRowkU1 $fGFromRowkM1 $fGFromRowkK1 $fGFromRowkU1$fGFromRowTYPE:*: insertStmtFor updateStmtFor selectStmtForselectAllStmtForselectAllWhereStmtFor deleteStmtForcreateTableStmtFordropTableStmtFor retrieveById retrieveAllretrieveAllWhereentitiesFromRowspersistinsert insertManyupdate updateManydelete setupTableForentityIdidValue$fConvertibleaSqlValue$fConvertibleSqlValuea withWConnHDBC-2.4.0.4-5c3a3ab2Database.HDBC.Types IConnectionDatabase.HDBC.SqlValueSqlValuebase GHC.Generics:*:GHC.Baseid columnTypeFor fieldIndexversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDirgetDataFileName getSysconfDir