https://github.com/agrafix/hasql-simple
Haskell: A somewhat opinionated "simpler" API to hasql
https://github.com/agrafix/hasql-simple
Last synced: about 1 year ago
JSON representation
Haskell: A somewhat opinionated "simpler" API to hasql
- Host: GitHub
- URL: https://github.com/agrafix/hasql-simple
- Owner: agrafix
- License: bsd-3-clause
- Created: 2017-09-14T09:38:36.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-14T14:27:59.000Z (over 8 years ago)
- Last Synced: 2025-04-04T15:46:22.294Z (about 1 year ago)
- Language: Haskell
- Size: 6.84 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hasql-simple
[](https://circleci.com/gh/agrafix/hasql-simple)
A somewhat opinionated "simpler" API to hasql. This allows to write code like:
```haskell
import Hasql.Query
import Hasql.Simple
import qualified Hasql.Decoders as D
data NewUser
= NewUser
{ nu_username :: !T.Text
, nu_email :: !T.Text
, nu_password :: !(Password 'PtHash)
} deriving (Show)
createUserQ :: Query NewUser UserId
createUserQ =
statement sql encoder decoder True
where
sql =
"INSERT INTO login (username, email, password) VALUES ($1, $2, $3) RETURNING id;"
encoder =
req nu_username
<> req nu_email
<> req nu_password
decoder =
D.singleRow dbDecVal
```
The `-simple` in the name is due to this type class approach beeing similar to the one found in `postgresql-simple`. All contributions (e.g. more instances and/or helper functions) are welcome, please send a PR.