Go to file
rightfold c1f9391701
Remove tuple machinery in favour of row types
These are more efficient and provide better error messages.
2017-06-03 13:27:14 +02:00
src/Database Remove tuple machinery in favour of row types 2017-06-03 13:27:14 +02:00
test Remove tuple machinery in favour of row types 2017-06-03 13:27:14 +02:00
.editorconfig Extract from dinote 2016-12-22 19:12:38 +01:00
.gitignore Extract from dinote 2016-12-22 19:12:38 +01:00
bower.json Remove tuple machinery in favour of row types 2017-06-03 13:27:14 +02:00
LICENSE Add license 2016-12-24 13:34:58 +01:00
Makefile Remove tuple machinery in favour of row types 2017-06-03 13:27:14 +02:00
package.json Add pg dependency 2016-12-22 22:10:28 +01:00
purspgpp Support OS X 2017-01-17 12:20:52 +01:00
PurspgppExample.purs Add command line parameter to purspgpp 2016-12-22 20:28:47 +01:00
README.md Clarify that purspgpp is optional 2017-05-06 16:52:50 +02:00
Rows.pl Remove tuple machinery in favour of row types 2017-06-03 13:27:14 +02:00

purescript-postgresql-client

purescript-postgresql-client is a PostgreSQL client library for PureScript.

To use this library, you need to add pg as an npm dependency.

Included is an optional preprocessor, purspgpp, which finds embedded SQL queries in PureScript source files and infers their types. Such queries can be written as follows:

userName = [query|
    SELECT first_name, last_name
    FROM users
    WHERE id = $1
|]

purspgpp will replace this by something like the following:

(Query """
    SELECT first_name, last_name
    FROM users
    WHERE id = $1
""" :: Query (Tuple UUID Unit) (Tuple String (Tuple String Unit))

You can integrate purspgpp into your build system. For example, here is a PowerShell script that executes it for all .purspg files:

Get-ChildItem src -Recurse -Filter *.purspg `
| ForEach-Object {
    perl6 `
        bower_components/purescript-postgresql-client/purspgpp `
        "user=postgres password=lol123 dbname=nn" `
        "$($_.FullName)" `
        "$([IO.Path]::ChangeExtension($_.FullName, "purs"))"
    if (!$?) {
        Write-Error "Unable to preprocess $_"
    }
}