An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# hasql-simple

[![CircleCI](https://circleci.com/gh/agrafix/hasql-simple.svg?style=svg)](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.