packages feed

sql-simple 0.2.0 → 0.3.0

raw patch · 3 files changed

+17/−4 lines, 3 filesdep +monad-controldep +transformers-base

Dependencies added: monad-control, transformers-base

Files

Database/Sql/Simple.hs view
@@ -16,6 +16,7 @@     , I.Sql     , I.Elem     , I.Backend+    , I.Transaction       -- * connection     , I.ConnectInfo     , I.withConnection@@ -77,10 +78,10 @@          => b -> I.Query -> (r -> IO ()) -> IO () forEach_ = I.forEach_ -begin, commit, rollback :: I.Backend b => b -> I.Sql bs ()+begin, commit, rollback :: I.Transaction b => b -> I.Sql bs () begin = I.begin commit = I.commit rollback = I.rollback -withTransaction :: I.Backend b => b -> I.Sql bs a -> I.Sql bs a+withTransaction :: I.Transaction b => b -> I.Sql bs a -> I.Sql bs a withTransaction = I.withTransaction
Database/Sql/Simple/Internal.hs view
@@ -14,8 +14,11 @@ module Database.Sql.Simple.Internal where  import GHC.Exts (Constraint)+import Control.Monad import Control.Monad.Catch import Control.Monad.IO.Class+import Control.Monad.Base+import Control.Monad.Trans.Control import Control.Applicative  import qualified Data.Text as T@@ -28,8 +31,14 @@     deriving (Show, Eq)  newtype Sql (l :: [*]) a = Sql { unSql :: IO a }-    deriving (Functor, Applicative, Monad, MonadIO, MonadThrow, MonadCatch, MonadMask)+    deriving (Functor, Applicative, Monad, MonadIO, MonadThrow, MonadCatch, MonadMask, MonadBase IO) +instance MonadBaseControl IO (Sql l) where+    newtype StM (Sql l) a = StMSql { unStMSql :: StM IO a }+    liftBaseWith f = Sql $ +        liftBaseWith (\run -> f $ liftM StMSql . run . unSql)+    restoreM = Sql . restoreM . unStMSql+ instance IsString Query where     fromString s = Query (T.pack s) H.empty @@ -75,6 +84,7 @@     forEach_ :: FromRow b r => b -> Query -> (r -> IO ()) -> IO ()     forEach_ c q    = fold_ c q () . const   +class Backend b => Transaction b where     begin    :: b -> Sql c ()     commit   :: b -> Sql c ()     rollback :: b -> Sql c ()
sql-simple.cabal view
@@ -1,5 +1,5 @@ name:                sql-simple-version:             0.2.0+version:             0.3.0 synopsis:            common middle-level sql client. description:         please read README.md <https://github.com/philopon/sql-simple/blob/master/README.md> license:             MIT@@ -22,6 +22,8 @@                      , text                 >=1.1 && <1.2                      , transformers         >=0.4 && <0.5                      , unordered-containers >=0.2 && <0.3+                     , monad-control        >=0.3 && <0.4+                     , transformers-base    >=0.4 && <0.5    if impl(ghc < 7.8)     build-depends:     tagged               >=0.7 && <0.8