packages feed

potoki-hasql 1.5 → 1.6

raw patch · 5 files changed

+41/−46 lines, 5 filesdep +acquiredep −potokidep ~potoki-core

Dependencies added: acquire

Dependencies removed: potoki

Dependency ranges changed: potoki-core

Files

library/Potoki/Hasql/Consume.hs view
@@ -1,21 +1,20 @@ module Potoki.Hasql.Consume where -import Potoki.Hasql.Prelude   -import Potoki.Hasql.Error.Types  -import Potoki.Core.Consume-import qualified Hasql.Connection as B-import qualified Hasql.Statement as E-import qualified Hasql.Session as D-import qualified Potoki.Consume as O-import qualified Potoki.Core.Fetch as C-import qualified Potoki.Transform as F+import           Potoki.Hasql.Prelude     hiding (concat)+import           Potoki.Hasql.Error.Types  +import           Potoki.Core.Consume+import qualified Hasql.Connection         as B+import qualified Hasql.Statement          as E+import qualified Hasql.Session            as D+import qualified Potoki.Core.Fetch        as C+import qualified Potoki.Core.Transform    as F import qualified Potoki.Hasql.Error.Hasql as G   executeBatchStatementConcurrently :: E.Statement (Vector params) () -> Int -> Int -> B.Settings -> Consume params (Either Error ()) executeBatchStatementConcurrently statement batchSize amountOfConnections settings =-  transform batchTransform (right' O.concat)+  transform batchTransform (right' concat)   where     batchTransform =       F.concurrently amountOfConnections (F.consume (executeBatchStatement statement batchSize settings))@@ -23,7 +22,7 @@ executeBatchStatement :: E.Statement (Vector params) () -> Int -> B.Settings -> Consume params (Either Error ()) executeBatchStatement statement batchSize settings =   transform-    (F.consume (transform (F.take batchSize) O.vector))+    (F.consume (transform (F.take batchSize) vector))     (executeStatement statement settings)  executeStatement :: E.Statement params () -> B.Settings -> Consume params (Either Error ())@@ -35,17 +34,16 @@   Consume $ \ (C.Fetch fetchIO) -> do     acquisitionResult <- B.acquire connectionSettings     case acquisitionResult of-      Left error -> return (Left (G.connectionError error))+      Left err -> return (Left (G.connectionError err))       Right connection ->         let-          loop =-            join $-            fetchIO-              (return (Right ()))-              (\ params ->-                do-                  result <- D.run (session params) connection-                  case result of-                    Right () -> loop-                    Left error -> return (Left (G.sessionError error)))-          in loop <* B.release connection+          doLoop = do+            fetch <- fetchIO+            case fetch of+              Nothing     -> return (Right ())+              Just params -> do+                result <- D.run (session params) connection+                case result of+                  Right () -> doLoop+                  Left err -> return (Left (G.sessionError err))+          in doLoop <* B.release connection
library/Potoki/Hasql/Error.hs view
@@ -1,12 +1,10 @@ module Potoki.Hasql.Error (     Error (..),-    module Potoki.Hasql.Error.Instances,     connectionError,     sessionError ) where  import Potoki.Hasql.Error.Hasql-import Potoki.Hasql.Error.Instances import Potoki.Hasql.Error.Types
library/Potoki/Hasql/Prelude.hs view
@@ -13,8 +13,8 @@ import           Data.String              as Exports import           Data.Profunctor          as Exports (right') import           Data.IORef               as Exports-import           Data.Vector              as Exports (Vector(..))-import           Data.Text                as Exports (Text(..))+import           Data.Vector              as Exports (Vector)+import           Data.Text                as Exports (Text) import           Control.Arrow            as Exports ((>>>)) import qualified Data.Text                as A import qualified Data.Text.Encoding       as A
library/Potoki/Hasql/Produce.hs view
@@ -9,15 +9,15 @@ import qualified Hasql.Session             as G import qualified Potoki.Core.Fetch         as A import           Potoki.Core.Produce-import qualified Potoki.Produce            as K-import qualified Potoki.Transform          as J+import qualified Potoki.Core.Transform     as J import qualified Potoki.Hasql.Error.Hasql  as I import           Potoki.Hasql.Error.Types+import qualified Acquire.Acquire           as B   vectorStatefulSession :: (state -> G.Session (Vector a, state)) -> state -> F.Settings -> Int -> Produce (Either Error a) vectorStatefulSession vectorSession initialState connectionConfig buffering =-  K.transform+  transform     (right' (J.takeWhile (not . D.null) >>> J.vector >>> J.bufferize buffering))     (statefulSession vectorSession initialState connectionConfig) @@ -25,29 +25,28 @@ statefulSession session initialState =   havingConnection $ \ connection -> do     stateRef <- newIORef initialState-    return $ A.Fetch $ \ nil just -> do+    return $ A.Fetch $ do       state <- readIORef stateRef       sessionResult <- G.run (session state) connection       case sessionResult of-        Left error -> return (just (Left (I.sessionError error)))+        Left err -> return (Just (Left (I.sessionError err)))         Right (result, newState) -> do           writeIORef stateRef newState-          return (just (Right result))+          return (Just (Right result))  havingConnection :: (F.Connection -> IO (A.Fetch (Either Error a))) -> F.Settings -> Produce (Either Error a) havingConnection cont connectionSettings =-  Produce $ do+  Produce $ B.Acquire $ do     errorOrConnection <- F.acquire connectionSettings     case errorOrConnection of-      Left error ->+      Left err ->         let           fetch =-            A.Fetch $ \ stop yield -> return (yield (Left (I.connectionError error)))+            A.Fetch $ return (Just (Left (I.connectionError err)))           kill =             return ()           in return (fetch, kill)       Right connection -> do         fetch <- cont connection-        let-          kill = F.release connection-          in return (fetch, kill)+        let kill = F.release connection+        return (fetch, kill)
potoki-hasql.cabal view
@@ -1,7 +1,7 @@ name:   potoki-hasql version:-  1.5+  1.6 synopsis:   Integration of "potoki" and "hasql". description:@@ -50,11 +50,11 @@     Potoki.Hasql.Error.Instances     Potoki.Hasql.Error.Types   build-depends:-    hasql >= 1.3 && < 1.4,-    potoki >= 0.11.1 && < 0.12,-    potoki-core >= 1.5.2 && < 1.6,+    acquire >= 0.2.0.1 && < 0.3,     base >= 4.10.1.0 && < 5,-    text >= 1.2.3.0 && < 1.3,     bytestring >= 0.10.8.2 && < 0.11,-    vector >= 0.12.0.1 && < 0.13,-    profunctors >= 5.2.2 && < 5.3+    hasql >= 1.3 && < 1.4,+    potoki-core >= 2.1 && < 2.2,+    profunctors >= 5.2.2 && < 5.3,+    text >= 1.2.3.0 && < 1.3,+    vector >= 0.12.0.1 && < 0.13