unexceptionalio-trans (empty) → 0.4.0
raw patch · 4 files changed
+179/−0 lines, 4 filesdep +basedep +transformersdep +unexceptionaliosetup-changed
Dependencies added: base, transformers, unexceptionalio
Files
- COPYING +13/−0
- Setup.hs +2/−0
- UnexceptionalIO/Trans.hs +127/−0
- unexceptionalio-trans.cabal +37/−0
+ COPYING view
@@ -0,0 +1,13 @@+Copyright © 2018, Stephen Paul Weber <singpolyma.net>++Permission to use, copy, modify, and/or distribute this software for any+purpose with or without fee is hereby granted, provided that the above+copyright notice and this permission notice appear in all copies.++THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ UnexceptionalIO/Trans.hs view
@@ -0,0 +1,127 @@+{-# LANGUAGE CPP #-}+-- | When you've caught all the exceptions that can be handled safely,+-- this is what you're left with.+--+-- > runExceptIO . fromIO ≡ id+--+-- It is intended that you use qualified imports with this library.+--+-- > import UnexceptionalIO.Trans (UIO)+-- > import qualified UnexceptionalIO.Trans as UIO+module UnexceptionalIO.Trans (+ UIO.UIO,+ UIO.Unexceptional(..),+ fromIO,+ run,+ runExceptIO,+ -- * Unsafe entry points+#ifdef __GLASGOW_HASKELL__+ fromIO',+#endif+ UIO.unsafeFromIO,+ -- * Pseudo exceptions+ UIO.SomeNonPseudoException,+#ifdef __GLASGOW_HASKELL__+ UIO.PseudoException(..),+ UIO.ProgrammerError(..),+ UIO.ExternalError(..),+ -- * Pseudo exception helpers+ UIO.bracket,+#if MIN_VERSION_base(4,6,0)+ UIO.forkFinally,+ UIO.fork+#endif+#endif+) where++import Control.Exception (Exception)+import Control.Monad.IO.Class (MonadIO(..))+#if MIN_VERSION_transformers(0,5,3)+import qualified Control.Monad.Trans.Accum as Trans+#endif+import qualified Control.Monad.Trans.Class as Trans+import qualified Control.Monad.Trans.Cont as Trans+import qualified Control.Monad.Trans.Error as Trans+import qualified Control.Monad.Trans.Except as Trans+import qualified Control.Monad.Trans.Identity as Trans+import qualified Control.Monad.Trans.List as Trans+import qualified Control.Monad.Trans.Maybe as Trans+import qualified Control.Monad.Trans.RWS.Lazy as RWSL+import qualified Control.Monad.Trans.RWS.Strict as RWSS+import qualified Control.Monad.Trans.Reader as Trans+#if MIN_VERSION_transformers(0,5,3)+import qualified Control.Monad.Trans.Select as Trans+#endif+import qualified Control.Monad.Trans.State.Lazy as StateL+import qualified Control.Monad.Trans.State.Strict as StateS+import qualified Control.Monad.Trans.Writer.Lazy as WriterL+import qualified Control.Monad.Trans.Writer.Strict as WriterS+import qualified UnexceptionalIO as UIO++-- | Catch any exception but 'PseudoException' in an 'IO' action+fromIO :: (UIO.Unexceptional m) => IO a -> Trans.ExceptT UIO.SomeNonPseudoException m a+fromIO = Trans.ExceptT . UIO.fromIO++-- | You promise that 'e' covers all exceptions but 'PseudoException'+-- thrown by this 'IO' action+--+-- This function is partial if you lie+fromIO' :: (Exception e, UIO.Unexceptional m) => IO a -> Trans.ExceptT e m a+fromIO' = Trans.ExceptT . UIO.fromIO'++-- | Re-embed 'UIO' into 'MonadIO'+run :: (MonadIO m) => UIO.UIO a -> m a+run = liftIO . UIO.run++-- | Re-embed 'UIO' and possible exception back into 'IO'+runExceptIO :: (Exception e, MonadIO m) => Trans.ExceptT e UIO.UIO a -> m a+runExceptIO = liftIO . UIO.runEitherIO . Trans.runExceptT++#if MIN_VERSION_transformers(0,5,3)+instance (UIO.Unexceptional m) => UIO.Unexceptional (Trans.AccumT w m) where+ lift = Trans.lift . UIO.lift+#endif++instance (UIO.Unexceptional m) => UIO.Unexceptional (Trans.ContT r m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m, Trans.Error e) => UIO.Unexceptional (Trans.ErrorT e m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m) => UIO.Unexceptional (Trans.ExceptT e m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m) => UIO.Unexceptional (Trans.IdentityT m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m) => UIO.Unexceptional (Trans.ListT m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m) => UIO.Unexceptional (Trans.MaybeT m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m, Monoid w) => UIO.Unexceptional (RWSL.RWST r w s m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m, Monoid w) => UIO.Unexceptional (RWSS.RWST r w s m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m) => UIO.Unexceptional (Trans.ReaderT r m) where+ lift = Trans.lift . UIO.lift++#if MIN_VERSION_transformers(0,5,3)+instance (UIO.Unexceptional m) => UIO.Unexceptional (Trans.SelectT r m) where+ lift = Trans.lift . UIO.lift+#endif++instance (UIO.Unexceptional m) => UIO.Unexceptional (StateL.StateT s m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m) => UIO.Unexceptional (StateS.StateT s m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m, Monoid w) => UIO.Unexceptional (WriterL.WriterT w m) where+ lift = Trans.lift . UIO.lift++instance (UIO.Unexceptional m, Monoid w) => UIO.Unexceptional (WriterS.WriterT w m) where+ lift = Trans.lift . UIO.lift
+ unexceptionalio-trans.cabal view
@@ -0,0 +1,37 @@+name: unexceptionalio-trans+version: 0.4.0+cabal-version: >=1.8+license: OtherLicense+license-file: COPYING+copyright: © 2013-2014 Stephen Paul Weber+category: Control+author: Stephen Paul Weber <singpolyma@singpolyma.net>+maintainer: Stephen Paul Weber <singpolyma@singpolyma.net>+stability: experimental+build-type: Simple+homepage: https://github.com/singpolyma/unexceptionalio-trans+bug-reports: http://github.com/singpolyma/unexceptionalio-trans/issues+synopsis: A wrapper around UnexceptionalIO using monad transformers+description:+ UnexceptionalIO provides a basic type to witness having caught all+ exceptions you can safely handle. This library builds on that with+ transformers like ExceptT to provide a more ergonomic tool for many+ cases.+ .+ It is intended that you use qualified imports with this library.+ .+ > import UnexceptionalIO.Trans (UIO)+ > import qualified UnexceptionalIO.Trans as UIO++library+ exposed-modules:+ UnexceptionalIO.Trans++ build-depends:+ base == 4.*,+ transformers,+ unexceptionalio == 0.4.0++source-repository head+ type: git+ location: git://github.com/singpolyma/unexceptionalio-trans.git