Compactable 0.1.0.0 → 0.1.0.1
raw patch · 2 files changed
+13/−3 lines, 2 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Control.Compactable: instance Control.Compactable.Compactable (Data.Functor.Const.Const r)
+ Control.Compactable: instance GHC.Base.Monoid m => Control.Compactable.Compactable (Data.Either.Either m)
Files
- Compactable.cabal +1/−1
- src/Control/Compactable.hs +12/−2
Compactable.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: Compactable-version: 0.1.0.0+version: 0.1.0.1 synopsis: A generalization for containers that can be stripped of Nothing description: Sometimes you have a collection of Maybes, and you want to extract the values. Actual that happens a whole lot.
src/Control/Compactable.hs view
@@ -200,7 +200,17 @@ instance Compactable Vector +instance Compactable (Const r) where+ compact (Const r) = Const r+ {-# INLINABLE compact #-} +instance Monoid m => Compactable (Either m) where+ compact (Right (Just x)) = Right x+ compact (Right _) = Left mempty+ compact (Left x) = Left x+ {-# INLINABLE compact #-}++ fforMaybe :: (Compactable f, Functor f) => f a -> (a -> Maybe b) -> f b fforMaybe = flip fmapMaybe @@ -218,11 +228,11 @@ applyMaybeM :: (Compactable f, Monad f) => f (a -> MaybeT f b) -> f a -> f b-applyMaybeM fa x = compact . join $ runMaybeT <$> (fa <*> x)+applyMaybeM fa = compact . join . fmap runMaybeT . (fa <*>) bindMaybeM :: (Compactable f, Monad f) => f a -> (a -> f (MaybeT f b)) -> f b-bindMaybeM x f = compact . join . fmap runMaybeT $ x >>= f+bindMaybeM x = compact . join . fmap runMaybeT . (x >>=) traverseMaybeM :: (Monad m, Compactable t, Traversable t) => (a -> MaybeT m b) -> t a -> m (t b)