packages feed

postgresql-tx-simple (empty) → 0.1.0.0

raw patch · 5 files changed

+150/−0 lines, 5 filesdep +basedep +postgresql-simpledep +postgresql-tx

Dependencies added: base, postgresql-simple, postgresql-tx, transformers

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Change log++## 0.1.0.0++Initial release
+ LICENSE.md view
@@ -0,0 +1,30 @@+Copyright SimSpace (c) 2020++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of SimSpace nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ package.yaml view
@@ -0,0 +1,28 @@+name:                postgresql-tx-simple+version:             0.1.0.0+github:              "simspace/postgresql-tx/simple"+license:             BSD3+license-file:        LICENSE.md+author:              "Cary Robbins"+maintainer:          "carymrobbins@gmail.com"+copyright:           "2020 SimSpace"+synopsis:            postgresql-tx interfacing for use with postgresql-simple.+category:            Database+description:         Please see the README on GitHub at <https://github.com/simspace/postgresql-tx#readme>++extra-source-files:+- CHANGELOG.md+- LICENSE.md+- package.yaml++ghc-options:+  - -Wall++dependencies:+- base >= 4.7 && < 5+- postgresql-simple >= 0.6.2 && < 0.7+- postgresql-tx >= 0.1.0.0 && < 0.2+- transformers >= 0.5.6.2 && < 0.6++library:+  source-dirs: src
+ postgresql-tx-simple.cabal view
@@ -0,0 +1,45 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.33.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: c49c4584915e0a9050d6fb99053fd27a445d8a627a7797f743efae7b38b42d34++name:           postgresql-tx-simple+version:        0.1.0.0+synopsis:       postgresql-tx interfacing for use with postgresql-simple.+description:    Please see the README on GitHub at <https://github.com/simspace/postgresql-tx#readme>+category:       Database+homepage:       https://github.com/simspace/postgresql-tx#readme+bug-reports:    https://github.com/simspace/postgresql-tx/issues+author:         Cary Robbins+maintainer:     carymrobbins@gmail.com+copyright:      2020 SimSpace+license:        BSD3+license-file:   LICENSE.md+build-type:     Simple+extra-source-files:+    CHANGELOG.md+    LICENSE.md+    package.yaml++source-repository head+  type: git+  location: https://github.com/simspace/postgresql-tx+  subdir: simple++library+  exposed-modules:+      Database.PostgreSQL.Tx.Simple+  other-modules:+      Paths_postgresql_tx_simple+  hs-source-dirs:+      src+  ghc-options: -Wall+  build-depends:+      base >=4.7 && <5+    , postgresql-simple >=0.6.2 && <0.7+    , postgresql-tx >=0.1.0.0 && <0.2+    , transformers >=0.5.6.2 && <0.6+  default-language: Haskell2010
+ src/Database/PostgreSQL/Tx/Simple.hs view
@@ -0,0 +1,42 @@+{-# LANGUAGE BlockArguments #-}+module Database.PostgreSQL.Tx.Simple where++import Control.Monad.Trans.Reader (ReaderT)+import Data.Int (Int64)+import Database.PostgreSQL.Tx (TxM, unsafeRunTxM, unsafeReaderIOTx)+import qualified Database.PostgreSQL.Simple as Simple+import qualified Database.PostgreSQL.Simple.Transaction as Simple++type PgSimpleM = ReaderT Simple.Connection TxM++withTransaction :: Simple.Connection -> TxM a -> IO a+withTransaction c x = Simple.withTransaction c (unsafeRunTxM x)++withTransactionLevel :: Simple.IsolationLevel -> Simple.Connection -> TxM a -> IO a+withTransactionLevel lvl c x = Simple.withTransactionLevel lvl c (unsafeRunTxM x)++unsafeFromPgSimple1+  :: (Simple.Connection -> a1 -> IO r)+  -> a1 -> PgSimpleM r+unsafeFromPgSimple1 f a1 = unsafeReaderIOTx \c -> f c a1++unsafeFromPgSimple2+  :: (Simple.Connection -> a1 -> a2 -> IO r)+  -> a1 -> a2 -> PgSimpleM r+unsafeFromPgSimple2 f a1 a2 = unsafeReaderIOTx \c -> f c a1 a2++-- | Re-export of 'Simple.query'+query :: (Simple.ToRow q, Simple.FromRow r) => Simple.Query -> q -> PgSimpleM [r]+query = unsafeFromPgSimple2 Simple.query++-- | Re-export of 'Simple.query_'+query_ :: (Simple.FromRow r) => Simple.Query -> PgSimpleM [r]+query_ = unsafeFromPgSimple1 Simple.query_++-- | Re-export of 'Simple.execute'+execute :: (Simple.ToRow q) => Simple.Query -> q -> PgSimpleM Int64+execute = unsafeFromPgSimple2 Simple.execute++-- | Re-export of 'Simple.execute_'+execute_ :: Simple.Query -> PgSimpleM Int64+execute_ = unsafeFromPgSimple1 Simple.execute_