Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for mkHsI out of date #12

Open
commandodev opened this issue Oct 13, 2016 · 0 comments
Open

Documentation for mkHsI out of date #12

commandodev opened this issue Oct 13, 2016 · 0 comments

Comments

@commandodev
Copy link

Example of use still refers to the old type class method:

Helper function to safely build an HsI t.

The type of this function isn't easy to understand, but an example should clarify its usage. We will asume we have a TPerson which is an instance of Table, and Person datatype as follows:

data TPerson

instance Table TPerson where
data T TPerson = TPerson
type Database TPerson = ... not important ...
type SchemaName TPerson = ... not important ...
type TableName TPerson = ... not important ...
type Columns TPerson
= '[ 'Col "name" W R PGText Text
, 'Col "age" W R PGInt4 Int32
]

data Person = Person
{ _personName :: Text
, _personAge :: Int
}
With that in place, and with the OverloadedLabels GHC extension enabled, we can use mkHsI as follows:

personToHsI :: Person -> HsI TPerson
personToHsI person =
mkHsI TPerson
(hsi #name (_personName person))
(hsi #age (_personAge age))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant