packages feed

hipsql-tx-simple (empty) → 0.0.0.0

raw patch · 4 files changed

+95/−0 lines, 4 filesdep +basedep +hipsql-monaddep +hipsql-server

Dependencies added: base, hipsql-monad, hipsql-server, postgresql-simple, postgresql-tx

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Changelog for hipsql-tx-simple++## 0.0.0.0++* Initial release
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright SimSpace (c) 2022++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.
+ hipsql-tx-simple.cabal view
@@ -0,0 +1,35 @@+cabal-version: 1.12++name:           hipsql-tx-simple+version:        0.0.0.0+description:    Please see the README on GitHub at <https://github.com/simspace/hipsql#readme>+homepage:       https://github.com/simspace/hipsql#readme+bug-reports:    https://github.com/simspace/hipsql/issues+author:         Cary Robbins+maintainer:     carymrobbins@gmail.com+copyright:      2022 SimSpace+license:        BSD3+license-file:   LICENSE+build-type:     Simple+extra-source-files:+    CHANGELOG.md++source-repository head+  type: git+  location: https://github.com/simspace/hipsql++library+  exposed-modules:+      Hipsql.Tx.Simple+  other-modules:+      Paths_hipsql_tx_simple+  hs-source-dirs:+      library+  ghc-options: -Wall+  build-depends:+      base >=4.7 && <5+    , hipsql-monad >=0.0.0.0 && <1+    , hipsql-server >=0.0.0.0 && <1+    , postgresql-simple >=0.6.4 && <1+    , postgresql-tx >=0.3.0.0 && <1+  default-language: Haskell2010
+ library/Hipsql/Tx/Simple.hs view
@@ -0,0 +1,25 @@+-- | Hipsql interop for @postgresql-tx-simple@.+--+-- N.B. The 'MonadHipsql' instance for 'TxM' is derived by defining+-- a 'MonadHipsqlAdapter' instance and importing the orphan from+-- "Hipsql.Server.Adapter".+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Hipsql.Tx.Simple+  ( hipsql+  ) where++import Database.PostgreSQL.Tx (TxEnv, TxM, askTxEnv)+import Database.PostgreSQL.Tx.Unsafe (unsafeRunIOInTxM)+import Hipsql.Monad (MonadHipsql(hipsql), MonadHipsqlAdapter(hipsqlAcquireLibPQ))+import Hipsql.Server.Adapter ()++import qualified Database.PostgreSQL.Simple as Simple+import qualified Database.PostgreSQL.Simple.Internal as Simple.Internal++instance (TxEnv Simple.Connection r) => MonadHipsqlAdapter (TxM r) where+  hipsqlAcquireLibPQ f = do+    conn <- askTxEnv+    unsafeRunIOInTxM $ Simple.Internal.withConnection conn f