packages feed

opaleye-trans 0.2.0 → 0.3.0

raw patch · 4 files changed

+14/−10 lines, 4 filesdep +transformers

Dependencies added: transformers

Files

examples/v1/RoseTree.hs view
@@ -95,7 +95,7 @@         (NodeP Nothing (pgInt4 bid) (pgInt4 nbid) (pgInt4 x))  -insertTree :: MonadBase IO m => Rose Int -> OpaleyeT m Int+insertTree :: MonadIO m => Rose Int -> OpaleyeT m Int insertTree (Node x xs) = transaction $ do     Just bid <- newBranch     Just rootId <- insertNode 0 bid x
examples/v2/RoseTree.hs view
@@ -119,7 +119,7 @@         (NodeP Nothing (pgInt4 bid) (pgInt4 x))  -insertTree :: MonadBase IO m => Rose Int -> OpaleyeT m Int+insertTree :: MonadIO m => Rose Int -> OpaleyeT m Int insertTree (Node x xs) = transaction $ do     Just bid <- newBranch     Just rootId <- insertNode 0 (Just bid) x
opaleye-trans.cabal view
@@ -1,5 +1,5 @@ name:                opaleye-trans-version:             0.2.0+version:             0.3.0 synopsis:            A monad transformer for Opaleye description:         A monad transformer for Opaleye homepage:            https://github.com/tomjaguarpaw/haskell-opaleye@@ -24,6 +24,7 @@   build-depends:     base                >=4.8 && <4.9,     mtl                 >=2.2 && <2.3,+    transformers        >=0.3 && <0.5,     transformers-base   >=0.4 && <0.5,     opaleye             >=0.4 && <0.5,     postgresql-simple   >=0.4 && <0.5,
src/Opaleye/Trans.hs view
@@ -31,11 +31,14 @@     , -- * Reexports       liftBase     , MonadBase+    , liftIO+    , MonadIO     , ask     , Int64     ) where  import           Control.Monad.Base              (MonadBase, liftBase)+import           Control.Monad.IO.Class          (MonadIO, liftIO) import           Control.Monad.Reader            (MonadReader, ReaderT (..),                                                   ask) import           Control.Monad.Trans             (MonadTrans (..))@@ -53,7 +56,7 @@  -- | The 'Opaleye' monad transformer newtype OpaleyeT m a = OpaleyeT { unOpaleyeT :: ReaderT Connection m a }-    deriving (Functor, Applicative, Monad, MonadTrans, MonadReader Connection)+    deriving (Functor, Applicative, Monad, MonadTrans, MonadIO, MonadReader Connection)   instance MonadBase b m => MonadBase b (OpaleyeT m) where@@ -66,10 +69,10 @@ -- TODO Handle exceptions  -withConn :: MonadBase IO m => (Connection -> IO a) -> OpaleyeT m a+withConn :: MonadIO m => (Connection -> IO a) -> OpaleyeT m a withConn f = do     conn <- ask-    liftBase (f conn)+    liftIO (f conn)   newtype Transaction a = Transaction { unTransaction :: ReaderT Connection IO a }@@ -77,13 +80,13 @@   -- | Run a postgresql transaction in the 'OpaleyeT' monad-transaction :: MonadBase IO m => Transaction a -> OpaleyeT m a-transaction (Transaction t) = withConn $ \conn -> +transaction :: MonadIO m => Transaction a -> OpaleyeT m a+transaction (Transaction t) = withConn $ \conn ->     withTransaction conn (runReaderT t conn)   -- | Execute a query without a literal transaction-run :: MonadBase IO m => Transaction a -> OpaleyeT m a+run :: MonadIO m => Transaction a -> OpaleyeT m a run (Transaction t) = withConn $ runReaderT t  @@ -139,7 +142,7 @@ -- -- Maybe not worth defining. This almost certainly does the wrong thing. insertManyReturning-    :: (MonadBase IO m, Default QueryRunner a b)+    :: (MonadIO m, Default QueryRunner a b)     => Table w r     -> (r -> a)     -> [w]