simple 0.10.0.2 → 0.10.0.3
raw patch · 2 files changed
+13/−10 lines, 2 filesdep ~monad-control
Dependency ranges changed: monad-control
Files
- simple.cabal +3/−3
- src/Web/Simple/Controller/Exception.hs +10/−7
simple.cabal view
@@ -1,5 +1,5 @@ name: simple-version: 0.10.0.2+version: 0.10.0.3 synopsis: A minimalist web framework for the WAI server interface description: @@ -67,7 +67,7 @@ , directory , filepath , mime-types- , monad-control+ , monad-control < 0.4 , mtl , simple-templates >= 0.7.0 , wai >= 3.0@@ -102,7 +102,7 @@ base < 6 , hspec , HUnit- , monad-control+ , monad-control < 0.4 , mtl , simple , transformers
src/Web/Simple/Controller/Exception.hs view
@@ -9,16 +9,19 @@ runInM act `E.onException` runInM handler finally :: Controller s a -> Controller s b -> Controller s a-finally act handler = do- res <- (act `onException` handler)- handler- return res+finally act next = control $ \runInM -> E.mask $ \restore -> do+ r <- restore (runInM act) `E.onException` (runInM next)+ _ <- runInM next+ return r bracket :: Controller s a -> (a -> Controller s b) -> (a -> Controller s c) -> Controller s c-bracket aquire release act = do- a <- aquire- act a `finally` release a+bracket aquire release act = control $ \runInM -> E.mask $ \restore -> do+ let release' a = runInM $ restoreM a >>= release+ a <- runInM aquire+ r <- (restore $ runInM $ restoreM a >>= act) `E.onException` release' a+ _ <- release' a+ return r handle :: E.Exception e => (e -> Controller s a) -> Controller s a -> Controller s a