persistent-sqlite 0.6.2 → 0.6.2.1
raw patch · 2 files changed
+26/−5 lines, 2 filesdep ~monad-control
Dependency ranges changed: monad-control
Files
- Database/Persist/Sqlite.hs +24/−3
- persistent-sqlite.cabal +2/−2
Database/Persist/Sqlite.hs view
@@ -1,5 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleContexts #-} -- | A sqlite backend for persistent. module Database.Persist.Sqlite ( withSqlitePool@@ -20,19 +22,26 @@ import Data.List (intercalate) import Data.IORef import qualified Data.Map as Map+#if MIN_VERSION_monad_control(0, 3, 0)+import Control.Monad.Trans.Control (MonadBaseControl, control)+import qualified Control.Exception as E+#define MBCIO MonadBaseControl IO+#else import Control.Monad.IO.Control (MonadControlIO) import Control.Exception.Control (finally)+#define MBCIO MonadControlIO+#endif import Data.Text (Text, pack, unpack) import Data.Neither (MEither (..), meither) import Data.Object -withSqlitePool :: MonadControlIO m+withSqlitePool :: (MonadIO m, MBCIO m) => Text -> Int -- ^ number of connections to open -> (ConnectionPool -> m a) -> m a withSqlitePool s = withSqlPool $ open' s -withSqliteConn :: MonadControlIO m => Text -> (Connection -> m a) -> m a+withSqliteConn :: (MonadIO m, MBCIO m) => Text -> (Connection -> m a) -> m a withSqliteConn = withSqlConn . open' open' :: Text -> IO Connection@@ -88,7 +97,8 @@ Sqlite.Done <- Sqlite.step stmt return () -withStmt' :: MonadControlIO m+withStmt'+ :: (MBCIO m, MonadIO m) => Sqlite.Statement -> [PersistValue] -> (RowPopper m -> m a)@@ -270,3 +280,14 @@ [] -> MLeft $ concat ["Invalid value for ", name, ": ", s] where s = unpack t++#if MIN_VERSION_monad_control(0, 3, 0)+finally :: MonadBaseControl IO m+ => m a -- ^ computation to run first+ -> m b -- ^ computation to run afterward (even if an exception was raised)+ -> m a+finally a sequel = control $ \runInIO ->+ E.finally (runInIO a)+ (runInIO sequel)+{-# INLINABLE finally #-}+#endif
persistent-sqlite.cabal view
@@ -1,5 +1,5 @@ name: persistent-sqlite-version: 0.6.2+version: 0.6.2.1 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -21,7 +21,7 @@ , bytestring >= 0.9.1 && < 0.10 , transformers >= 0.2.1 && < 0.3 , persistent >= 0.6.3 && < 0.7- , monad-control >= 0.2 && < 0.3+ , monad-control >= 0.2 && < 0.4 , containers >= 0.2 && < 0.5 , text >= 0.7 && < 0.12 , data-object >= 0.3 && < 0.4