diff options
author | joe <joe@jerkface.net> | 2014-07-30 01:22:50 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-07-30 01:22:50 -0400 |
commit | ab8927d7d78d70f5074bb7b1415c9ac4547ea9b3 (patch) | |
tree | 34924648f50a48483f7ecfbf5efb71280d6dee0d /TraversableT.hs | |
parent | acd9892756839df0de60ef4d9c25a7057f8d40b6 (diff) |
cabal file adjustments
Diffstat (limited to 'TraversableT.hs')
-rw-r--r-- | TraversableT.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/TraversableT.hs b/TraversableT.hs index 98a97bf6..cc187951 100644 --- a/TraversableT.hs +++ b/TraversableT.hs | |||
@@ -4,7 +4,7 @@ import Data.Traversable | |||
4 | import Control.Monad (join,MonadPlus(..)) | 4 | import Control.Monad (join,MonadPlus(..)) |
5 | import Control.Monad.Trans.Class | 5 | import Control.Monad.Trans.Class |
6 | import Control.Applicative | 6 | import Control.Applicative |
7 | import Data.Foldable (Foldable(foldMap)) | 7 | import Data.Foldable (Foldable(foldMap), toList) |
8 | import Data.Maybe (maybeToList) | 8 | import Data.Maybe (maybeToList) |
9 | 9 | ||
10 | -- | | 10 | -- | |
@@ -82,3 +82,13 @@ liftMaybe = liftT . maybeToList | |||
82 | liftIOMaybe :: IO (Maybe a) -> TraversableT [] IO a | 82 | liftIOMaybe :: IO (Maybe a) -> TraversableT [] IO a |
83 | liftIOMaybe = liftMT . fmap maybeToList | 83 | liftIOMaybe = liftMT . fmap maybeToList |
84 | 84 | ||
85 | handleT :: ( Monad m | ||
86 | , Traversable t ) => | ||
87 | (t a -> TraversableT t m a) | ||
88 | -> TraversableT t m a | ||
89 | -> TraversableT t m a | ||
90 | handleT catcher body = TraversableT $ do | ||
91 | tx <- runTraversableT body | ||
92 | if null (toList tx) | ||
93 | then runTraversableT $ catcher tx | ||
94 | else return tx | ||