writer-cps-exceptions (empty) → 0.1.0.0
raw patch · 6 files changed
+144/−0 lines, 6 filesdep +basedep +exceptionsdep +transformerssetup-changed
Dependencies added: base, exceptions, transformers, writer-cps-transformers
Files
- LICENSE +32/−0
- README.md +7/−0
- Setup.hs +2/−0
- src/Control/Monad/Trans/RWS/CPS/Exceptions.hs +36/−0
- src/Control/Monad/Trans/Writer/CPS/Exceptions.hs +37/−0
- writer-cps-exceptions.cabal +30/−0
+ LICENSE view
@@ -0,0 +1,32 @@+Copyright (C) 2018 Daniel Mendler+Copyright (C) 2013-2015 Edward Kmett+Copyright (C) 2012 Google Inc.++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Author name here nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,7 @@+# Control.Monad.Catch instances for CPS WriterT and RWST monad transformers++[](https://hackage.haskell.org/package/writer-cps-exceptions)+[](http://travis-ci.org/minad/writer-cps-exceptions)+* https://hackage.haskell.org/package/writer-cps-transformers+* https://hackage.haskell.org/package/writer-cps-mtl+* https://hackage.haskell.org/package/writer-cps-execeptions
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Control/Monad/Trans/RWS/CPS/Exceptions.hs view
@@ -0,0 +1,36 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Control.Monad.Trans.RWS.CPS.Exceptions where++import Control.Monad.Trans.Class+import Control.Monad.Catch+import Control.Monad.Trans.RWS.CPS++instance (MonadThrow m, Monoid w) => MonadThrow (RWST r w s m) where+ throwM e = lift $ throwM e+instance (MonadCatch m, Monoid w) => MonadCatch (RWST r w s m) where+ catch m h = rwsT $ \r s -> runRWST m r s `catch` \e -> runRWST (h e) r s+instance (MonadMask m, Monoid w) => MonadMask (RWST r w s m) where+ mask a = rwsT $ \r s -> mask $ \u -> runRWST (a $ q u) r s+ where q u b = rwsT $ \ r s -> u (runRWST b r s)+ uninterruptibleMask a =+ rwsT $ \r s -> uninterruptibleMask $ \u -> runRWST (a $ q u) r s+ where q u b = rwsT $ \ r s -> u (runRWST b r s)++ generalBracket acquire release use = rwsT $ \r s0 -> do+ ((b, _s2, _w12), (c, s3, w123)) <- generalBracket+ (runRWST acquire r s0)+ (\(resource, s1, w1) exitCase -> case exitCase of+ ExitCaseSuccess (b, s2, w12) -> do+ (c, s3, w3) <- runRWST (release resource (ExitCaseSuccess b)) r s2+ return (c, s3, mappend w12 w3)+ ExitCaseException e -> do+ (c, s3, w3) <- runRWST (release resource (ExitCaseException e)) r s1+ return (c, s3, mappend w1 w3)+ ExitCaseAbort -> do+ (c, s3, w3) <- runRWST (release resource ExitCaseAbort) r s1+ return (c, s3, mappend w1 w3))+ (\(resource, s1, w1) -> do+ (a, s2, w2) <- runRWST (use resource) r s1+ return (a, s2, mappend w1 w2))+ return ((b, c), s3, w123)
+ src/Control/Monad/Trans/Writer/CPS/Exceptions.hs view
@@ -0,0 +1,37 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Control.Monad.Trans.Writer.CPS.Exceptions where++import Control.Monad.Trans.Class+import Control.Monad.Catch+import Control.Monad.Trans.Writer.CPS++instance (MonadThrow m, Monoid w) => MonadThrow (WriterT w m) where+ throwM e = lift $ throwM e++instance (MonadCatch m, Monoid w) => MonadCatch (WriterT w m) where+ catch m h = writerT $ runWriterT m `catch ` \e -> runWriterT (h e)++instance (MonadMask m, Monoid w) => MonadMask (WriterT w m) where+ mask a = writerT $ mask $ \u -> runWriterT (a $ q u)+ where q u b = writerT $ u (runWriterT b)+ uninterruptibleMask a =+ writerT $ uninterruptibleMask $ \u -> runWriterT (a $ q u)+ where q u b = writerT $ u (runWriterT b)+ generalBracket acquire release use = writerT $ do+ ((b, _w12), (c, w123)) <- generalBracket+ (runWriterT acquire)+ (\(resource, w1) exitCase -> case exitCase of+ ExitCaseSuccess (b, w12) -> do+ (c, w3) <- runWriterT (release resource (ExitCaseSuccess b))+ return (c, mappend w12 w3)+ ExitCaseException e -> do+ (c, w3) <- runWriterT (release resource (ExitCaseException e))+ return (c, mappend w1 w3)+ ExitCaseAbort -> do+ (c, w3) <- runWriterT (release resource ExitCaseAbort)+ return (c, mappend w1 w3))+ (\(resource, w1) -> do+ (a, w2) <- runWriterT (use resource)+ return (a, mappend w1 w2))+ return ((b, c), w123)
+ writer-cps-exceptions.cabal view
@@ -0,0 +1,30 @@+name: writer-cps-exceptions+version: 0.1.0.0+synopsis: Control.Monad.Catch instances for the stricter CPS WriterT and RWST+description: Control.Monad.Catch instances for the stricter WriterT and RWST from writer-cps-transformers.+homepage: https://github.com/minad/writer-cps-exceptions+license: BSD3+license-file: LICENSE+author: Daniel Mendler+maintainer: mail@daniel-mendler.de+copyright: 2018 Daniel Mendler, 2013-2015 Edward Kmett, 2012 Google Inc+category: Control+build-type: Simple+extra-source-files: README.md+cabal-version: >=1.10+tested-with: GHC == 7.10.3, GHC == 8.0.1, GHC == 8.2.1, GHC == 8.4.3, GHC == 8.6.1++library+ hs-source-dirs: src+ exposed-modules: Control.Monad.Trans.RWS.CPS.Exceptions+ , Control.Monad.Trans.Writer.CPS.Exceptions+ build-depends: base < 6+ , writer-cps-transformers >= 0.1.1.2+ , transformers >= 0.4 && < 0.6+ , exceptions >= 0.10 && < 0.12+ ghc-options: -Wall+ default-language: Haskell2010++source-repository head+ type: git+ location: https://github.com/minad/writer-cps-exceptions