witherable 0.0 → 0.1
raw patch · 2 files changed
+5/−7 lines, 2 files
Files
- src/Data/Witherable.hs +4/−3
- witherable.cabal +1/−4
src/Data/Witherable.hs view
@@ -10,6 +10,7 @@ import qualified Data.Foldable as F import Data.Hashable import Data.Functor.Identity +import Control.Monad.Trans.Maybe -- | Like `traverse`, but you can remove elements instead of updating them. -- @traverse f = wither (fmap Just . f)@ @@ -22,11 +23,11 @@ catMaybes :: Witherable t => t (Maybe a) -> t a catMaybes = runIdentity . wither pure - witherM :: Monad m => (a -> m (Maybe b)) -> t a -> m (t b) - witherM f = unwrapMonad . wither (WrapMonad . f) + witherM :: Monad m => (a -> MaybeT m b) -> t a -> m (t b) + witherM f = unwrapMonad . wither (WrapMonad . runMaybeT . f) -- | 'blightM' is 'witherM' with its arguments flipped. -blightM :: (Monad m, Witherable t) => t a -> (a -> m (Maybe b)) -> m (t b) +blightM :: (Monad m, Witherable t) => t a -> (a -> MaybeT m b) -> m (t b) blightM = flip witherM {-# INLINE blightM #-}
witherable.cabal view
@@ -1,8 +1,5 @@--- Initial witherable.cabal generated by cabal init. For further --- documentation, see http://haskell.org/cabal/users-guide/ - name: witherable -version: 0.0 +version: 0.1 synopsis: Generalization of catMaybes -- description: homepage: https://github.com/fumieval/witherable