packages feed

scottish 0.1.0.0 → 0.1.0.1

raw patch · 3 files changed

+31/−15 lines, 3 filesdep +enclosed-exceptions

Dependencies added: enclosed-exceptions

Files

README.md view
@@ -2,3 +2,6 @@  Provides global read-only configuration and global/action-local read-write states to [Scotty](https://github.com/scotty-web/scotty).++For now, `scottish` also provides helpers for database access, especially with+persistent.
scottish.cabal view
@@ -1,5 +1,5 @@ name:                scottish-version:             0.1.0.0+version:             0.1.0.1 synopsis:            scotty with batteries included description:   Scotty web framework with batteries included. For configurations/states, you@@ -45,19 +45,20 @@   exposed-modules:     Web.Scottish,                        Web.Scottish.Database                        Web.Scottish.Database.Persist-  build-depends:       base          >=4.6     && <4.7-                     , data-default  >=0.5     && <0.6-                     , http-types    >= 0.8    && <0.9-                     , lens          >=3.10    && <4.1-                     , mtl           >=2.1     && <2.2-                     , persistent    >=1.3     && <1.4-                     , resource-pool >=0.2     && <0.3-                     , scotty        >=0.6     && <0.8-                     , stm           >=2.4     && <2.5-                     , text          >=1.0     && <1.1-                     , transformers  >=0.3     && <0.4-                     , wai           >=2.0     && <2.2-                     , warp          >=2.0.3.3 && <2.2+  build-depends:       base                >=4.6     && <4.7+                     , data-default        >=0.5     && <0.6+                     , enclosed-exceptions >=1.0     && <1.1+                     , http-types          >=0.8     && <0.9+                     , lens                >=3.10    && <4.1+                     , mtl                 >=2.1     && <2.2+                     , persistent          >=1.3     && <1.4+                     , resource-pool       >=0.2     && <0.3+                     , scotty              >=0.6     && <0.8+                     , stm                 >=2.4     && <2.5+                     , text                >=1.0     && <1.1+                     , transformers        >=0.3     && <0.4+                     , wai                 >=2.0     && <2.2+                     , warp                >=2.0.3.3 && <2.2   hs-source-dirs:      src   default-language:    Haskell2010   ghc-options:         -Wall -fno-warn-orphans
src/Web/Scottish/Database/Persist.hs view
@@ -4,14 +4,26 @@ -} module Web.Scottish.Database.Persist where +import Control.Exception.Enclosed import Control.Monad.IO.Class import Control.Monad.Trans.Class +import Data.Functor+ import Database.Persist.Sql +import Network.HTTP.Types.Status+ import Web.Scottish import Web.Scottish.Database  runSql :: (MonadTrans t, HasDatabaseConnectionPool Connection config)-         => SqlPersistM a -> t (Scottish config s s') a+       => SqlPersistM a -> t (Scottish config s s') a runSql s = liftIO . runSqlPersistMPool s >$< getPool++-- | Catches any synchronous exceptions thrown when executing the database+-- transaction, and 'raise' an 'internalServerError500' instead.+runSql' :: (HasDatabaseConnectionPool Connection config)+        => SqlPersistM a -> ScottishActionM' config s' a+runSql' s = (runSql $ (Just <$> s) `catchAny` \_ -> return Nothing)+            >>= maybe (raise internalServerError500) return