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
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))
The text was updated successfully, but these errors were encountered:
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))
The text was updated successfully, but these errors were encountered: