hasql-simple: A somewhat opinionated "simpler" API to hasql

[ bsd3, library, web ] [ Propose Tags ]

A somewhat opinionated "simpler" API to hasql


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Dependencies aeson (>=1.1), base (>=4.7 && <5), bytestring (>=0.10), contravariant (>=1.4), hasql, text (>=1.2), time (>=1.6), unordered-containers (>=0.2), vector (>=0.12) [details]
License BSD-3-Clause
Copyright 2017 Alexander Thiemann <mail@athiemann.net>
Author Alexander Thiemann
Maintainer mail@athiemann.net
Category Web
Home page https://github.com/agrafix/hasql-simple#readme
Source repo head: git clone https://github.com/agrafix/hasql-simple
Uploaded by AlexanderThiemann at 2017-09-23T21:18:11Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 953 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-09-23 [all 1 reports]

Readme for hasql-simple-0.1.0.0

[back to package description]

hasql-simple

CircleCI

A somewhat opinionated "simpler" API to hasql. This allows to write code like:

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.