lmonad-yesod 0.1.0.0 → 0.2.0.0
raw patch · 3 files changed
+23/−3 lines, 3 files
Files
- lmonad-yesod.cabal +3/−2
- src/Database/LPersist.hs +19/−0
- src/Internal.hs +1/−1
lmonad-yesod.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.0+version: 0.2.0.0 -- A short (one-line) description of the package. synopsis: LMonad for Yesod integrates LMonad's IFC with Yesod web applications.@@ -61,13 +61,14 @@ src ghc-options:- -Wall -fno-warn-name-shadowing+ -Wall -fno-warn-name-shadowing -fno-warn-orphans extensions: FunctionalDependencies GADTs RankNTypes MultiParamTypeClasses+ FlexibleInstances -- Other library packages from which modules are imported. build-depends:
src/Database/LPersist.hs view
@@ -45,6 +45,7 @@ , updateGet , pUpdateGet , getJust+ , pGetJust , getBy , pGetBy , deleteBy@@ -52,8 +53,10 @@ , updateWhere , deleteWhere , selectFirst+ , pSelectFirst , count , selectList+ , pSelectList , selectKeysList ) where @@ -191,6 +194,11 @@ where err = liftIO $ throwIO $ Persist.PersistForeignConstraintUnmet $ Text.pack $ Prelude.show key +pGetJust :: (LMonad m, Label l, LEntity l v, MonadIO m, PersistStore backend, backend ~ PersistEntityBackend v, PersistEntity v, ProtectedEntity l v p) => (Key v) -> ReaderT backend (LMonadT l m) p+pGetJust key = pGet key >>= maybe err return+ where+ err = liftIO $ throwIO $ Persist.PersistForeignConstraintUnmet $ Text.pack $ Prelude.show key+ -- TODO -- -- belongsTo@@ -257,6 +265,11 @@ whenJust res $ lift . raiseLabelRead return res +pSelectFirst :: (PersistQuery backend, LMonad m, Label l, LEntity l v, MonadIO m, PersistStore backend, backend ~ PersistEntityBackend v, PersistEntity v, ProtectedEntity l v p) => [Filter v] -> [SelectOpt v] -> ReaderT backend (LMonadT l m) (Maybe p)+pSelectFirst filts opts = do+ res <- Persist.selectFirst filts opts+ lift $ maybe (return Nothing) (fmap Just . toProtected) res+ count :: (PersistQuery backend, LMonad m, Label l, LEntity l v, MonadIO m, PersistStore backend, backend ~ PersistEntityBackend v, PersistEntity v) => [Filter v] -> ReaderT backend (LMonadT l m) Int count filts = do res <- Persist.selectList filts []@@ -271,6 +284,12 @@ l <- Persist.selectList filts opts lift $ mapM_ raiseLabelRead l return l++pSelectList :: (PersistQuery backend, LMonad m, Label l, LEntity l v, MonadIO m, PersistStore backend, backend ~ PersistEntityBackend v, PersistEntity v, ProtectedEntity l v p) => [Filter v] -> [SelectOpt v] -> ReaderT backend (LMonadT l m) [p]+pSelectList filts opts = do+ l <- Persist.selectList filts opts+ lift $ mapM toProtected l + selectKeysList :: (PersistQuery backend, LMonad m, Label l, LEntity l v, MonadIO m, PersistStore backend, backend ~ PersistEntityBackend v, PersistEntity v) => [Filter v] -> [SelectOpt v] -> ReaderT backend (LMonadT l m) [Key v] selectKeysList filts opts = do
src/Internal.hs view
@@ -126,7 +126,7 @@ | "nullable" `elem` s = True | otherwise = False createContainsId [] = False- createContainsId (LAId:t) = True+ createContainsId (LAId:_) = True createContainsId (_:t) = createContainsId t -- Parse chevrons