You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment you need to write the "set-up" function by hands. Though, it mostly duplicates the type definition and translates types into the corresponding functions.
What would be great is to have the function createTables (or any other name) which would do this for you:
This is not an uncommon approach. You can see as the example of the servant-client library. client function generates a set of client functions for an API by a given Proxy api:
It is a bit redundant and it would be cool to auto-generate CREATE statements. However, it's not entirely redundant because while the type-level DSL says if a column has a DEFAULT, it doesn't say what that DEFAULT is so at the very least you'd need to specify that at the term-level. Similarly for CHECK constraints. With that in mind, for anyone who wants to try their hand at writing functions that auto-generate CREATE statements, it would be a worthwhile endeavor.
At the moment you need to write the "set-up" function by hands. Though, it mostly duplicates the type definition and translates types into the corresponding functions.
What would be great is to have the function
createTables
(or any other name) which would do this for you:Example
Let's say we have this schema:
to setup it now I would need to do the following:
If the
createTable
function would be implemented instead of that you could do just:This approach
This is not an uncommon approach. You can see as the example of the
servant-client
library.client
function generates a set of client functions for an API by a givenProxy api
:The text was updated successfully, but these errors were encountered: