streaming-postgresql-simple 0.2.0.2 → 0.2.0.3
raw patch · 3 files changed
+25/−3 lines, 3 files
Files
- ChangeLog.md +7/−0
- Database/PostgreSQL/Simple/Streaming.hs +17/−2
- streaming-postgresql-simple.cabal +1/−1
ChangeLog.md view
@@ -1,5 +1,12 @@ # Revision history for streaming-postgresql-simple +## 0.2.0.3 -- 2018-01-02++* Inline the exception handling code. In `streaming-0.1` this was provided by+ `exceptions` instances, but in `streaming-0.2` these instances were removed.+ Rather than rely on the instances, I've just added the implementations+ privately.+ ## 0.2.0.2 -- 2018-01-02 * Increase upper-bound of `streaming` to allow for 0.2
Database/PostgreSQL/Simple/Streaming.hs view
@@ -35,9 +35,8 @@ ) where import Control.Exception.Safe- (MonadMask, catch, throwM, mask)+ (Exception, MonadCatch, MonadMask, SomeException(..), catch, throwM, mask) import Control.Monad (unless)-import Control.Monad.Catch (onException) import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Reader (runReaderT)@@ -506,6 +505,22 @@ Return r -> Effect (unprotect key >> return (Return r)) Effect m -> Effect (fmap loop m) Step f -> Step (fmap loop f)++catchStream :: (Functor f, Exception e, MonadCatch m) => Stream f m a -> (e -> Stream f m a) -> Stream f m a+catchStream str f = go str+ where+ go p = case p of+ Step g -> Step (fmap go g)+ Return r -> Return r+ Effect m -> Effect (catch (do+ p' <- m+ return (go p'))+ (\e -> return (f e)) )++onException :: (Functor f, MonadCatch m) => Stream f m a -> Stream f m b -> Stream f m a+onException action handler =+ action `catchStream` \e@SomeException{} -> handler >> lift (throwM e)+ -- | Issue a @COPY FROM STDIN@ query and stream the results in. --
streaming-postgresql-simple.cabal view
@@ -1,5 +1,5 @@ name: streaming-postgresql-simple-version: 0.2.0.2+version: 0.2.0.3 cabal-version: >=1.10 build-type: Simple license: BSD3