packages feed

compactable 0.1.1.0 → 0.1.1.1

raw patch · 2 files changed

+40/−7 lines, 2 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Control.Compactable: fforBifold :: (CompactFold f, Functor f, Bifoldable g) => f a -> (a -> g l r) -> (f l, f r)
+ Control.Compactable: fforFold :: (CompactFold f, Functor f, Foldable g) => f a -> (a -> g b) -> f b

Files

compactable.cabal view
@@ -1,5 +1,5 @@ name:                compactable-version:             0.1.1.0+version:             0.1.1.1 synopsis:            A typeclass for structures which can be catMaybed, filtered, and partitioned. description:         This provides polymorphic implimentations for filter, compact (catMaybes), and separate. It allows for higher performance implimentations to be used in place of defaults for all data structures, and endeavors to centerally document those implimentations. Compactable aims to be as general and unconstrained as possible, providing instances for non-Functors like Set, as well as some Contravariants (though not published here). Compactable fully subsumes Data.Witherable, offers more laws, and is more general. license:             BSD3
src/Control/Compactable.hs view
@@ -5,9 +5,21 @@ {-# LANGUAGE LambdaCase                 #-}  module Control.Compactable-  ( Compactable (..)+  (+  -- * Compact+    Compactable (..)+  -- * Compact Fold+  , CompactFold (..)+  -- * Handly flips   , fforMaybe+  , fforFold   , fforEither+  , fforBifold+  -- * More general lefts and rights+  , mfold'+  , mlefts+  , mrights+  -- * Monad Transformer utils   , fmapMaybeM   , fmapEitherM   , fforMaybeM@@ -15,12 +27,10 @@   , applyMaybeM   , bindMaybeM   , traverseMaybeM+  -- * Alternative Defaults   , altDefaultCompact   , altDefaultSeparate-  , mfold'-  , mlefts-  , mrights-  , CompactFold (..)) where+  ) where  import           Control.Applicative import           Control.Arrow@@ -48,7 +58,6 @@ {-| Class 'Compactable' provides two methods which can be writen in terms of each other, compact and separate. -=Compact is generalization of catMaybes as a new function. Compact has relations with Functor, Applicative, Monad, Alternative, and Traversable. In that we can use these class to provide the ability to operate on a data type@@ -384,6 +393,22 @@     mempty = mzero     MonadSum a `mappend` MonadSum b = MonadSum (mplus a b) ++{-|+class `CompactFold` provides the same methods as `Compactable` but generalized to work on any `Foldable`.++When a type has MonadPlus (or similar) properties, we can extract the Maybe and the Either, and generalize to Foldable and Bifoldable.++Compactable can always be described in terms of CompactFold, because++  @compact = compactFold@++and++  @separate = separateFold@++as it's just a specialization. More exploration is needed on the relationship here.+-} class Compactable f => CompactFold (f :: * -> *) where     compactFold :: Foldable g => f (g a) -> f a     default compactFold :: (MonadPlus f, Foldable g) => f (g a) -> f a@@ -453,8 +478,16 @@ fforMaybe = flip fmapMaybe  +fforFold :: (CompactFold f, Functor f, Foldable g) => f a -> (a -> g b) -> f b+fforFold = flip fmapFold++ fforEither :: (Compactable f, Functor f) => f a -> (a -> Either l r) -> (f l, f r) fforEither = flip fmapEither+++fforBifold :: (CompactFold f, Functor f, Bifoldable g) => f a -> (a -> g l r) -> (f l, f r)+fforBifold = flip fmapBifold   fmapMaybeM :: (Compactable f, Monad f) => (a -> MaybeT f b) -> f a -> f b