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
Copy file name to clipboardExpand all lines: README.md
+35-10Lines changed: 35 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,40 +2,65 @@
2
2
3
3
## Summary
4
4
5
-
`postgresql-transactional` is a simple monadic wrapper around the SQL primitives introduced by the [postgresql-simple][psqls] package. It provides simple and predictable semantics for database operations, enforces awareness of Postgres's transactional nature at API boundaries, and obviates the need for transaction boilerplate in SQL queries.
5
+
`postgresql-transactional` is a simple monadic wrapper around the SQL
6
+
primitives introduced by the [postgresql-simple][psqls] package. It provides
7
+
simple and predictable semantics for database operations, enforces awareness of
8
+
Postgres's transactional nature at API boundaries, and obviates the need for
9
+
transaction boilerplate in SQL queries.
6
10
7
11
## Details
8
12
9
-
Though the primitives provided by the [postgresql-simple][psqls] package are fast and powerful, their interface is (by design) very basic: specifically, all query functions take a shared `Connection` parameter and operate in the `IO` monad.
13
+
Though the primitives provided by the [postgresql-simple][psqls] package are
14
+
fast and powerful, their interface is (by design) very basic: specifically, all
15
+
query functions take a shared `Connection` parameter and operate in the `IO`
16
+
monad.
10
17
11
18
```haskell
12
19
query::FromRowr=>Connection->Query->IO [r]
13
20
execute::ToRowq=>Connection->Query->q->IOInt64
14
21
```
15
22
16
-
By virtue of the fact that (usually) all queries in a given scope are routed through a single `Connection`, we can abstract away the shared `Connection` parameter by wrapping a `ReaderTConnection` around the `IO` monad:
23
+
By virtue of the fact that (usually) all queries in a given scope are routed
24
+
through a single `Connection`, we can abstract away the shared `Connection`
25
+
parameter by wrapping a `ReaderTConnection` in a monad transformer:
And we can then use the [postgresql-simple][psqls] `withTransaction` function to provide `runPGTransaction`, which executes a given `PGTransaction` block with rollback semantics:
47
+
And we can then use the [postgresql-simple][psqls] `withTransaction` function
48
+
to provide `runPGTransaction`, which executes a given `PGTransactionT` block
0 commit comments