summaryrefslogtreecommitdiff
path: root/TraversableT.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-07-30 01:22:50 -0400
committerjoe <joe@jerkface.net>2014-07-30 01:22:50 -0400
commitab8927d7d78d70f5074bb7b1415c9ac4547ea9b3 (patch)
tree34924648f50a48483f7ecfbf5efb71280d6dee0d /TraversableT.hs
parentacd9892756839df0de60ef4d9c25a7057f8d40b6 (diff)
cabal file adjustments
Diffstat (limited to 'TraversableT.hs')
-rw-r--r--TraversableT.hs12
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
4import Control.Monad (join,MonadPlus(..)) 4import Control.Monad (join,MonadPlus(..))
5import Control.Monad.Trans.Class 5import Control.Monad.Trans.Class
6import Control.Applicative 6import Control.Applicative
7import Data.Foldable (Foldable(foldMap)) 7import Data.Foldable (Foldable(foldMap), toList)
8import Data.Maybe (maybeToList) 8import Data.Maybe (maybeToList)
9 9
10-- | 10-- |
@@ -82,3 +82,13 @@ liftMaybe = liftT . maybeToList
82liftIOMaybe :: IO (Maybe a) -> TraversableT [] IO a 82liftIOMaybe :: IO (Maybe a) -> TraversableT [] IO a
83liftIOMaybe = liftMT . fmap maybeToList 83liftIOMaybe = liftMT . fmap maybeToList
84 84
85handleT :: ( Monad m
86 , Traversable t ) =>
87 (t a -> TraversableT t m a)
88 -> TraversableT t m a
89 -> TraversableT t m a
90handleT catcher body = TraversableT $ do
91 tx <- runTraversableT body
92 if null (toList tx)
93 then runTraversableT $ catcher tx
94 else return tx