-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A typeclass for structures which can be catMaybed, filtered, and partitioned. -- -- 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. @package compactable @version 0.1.0.4 module Control.Compactable -- | 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 by throwing away intermediate Nothings. This is -- useful for representing stripping out values or failure. -- -- To be compactable alone, no laws must be satisfied other than the type -- signature. -- -- If the data type is also a Functor the following should hold: -- -- -- -- According to Kmett, (Compactable f, Functor f) is a functor from the -- kleisli category of Maybe to the category of haskell data types. -- Kleisli Maybe -> Hask. -- -- If the data type is also Applicative the following should hold: -- -- -- -- If the data type is also a Monad the following should hold: -- -- -- -- If the data type is also Alternative the following should hold: -- -- -- -- If the data type is also Traversable the following should hold: -- -- -- --

Separate and filter

-- -- have recently elevated roles in this typeclass, and is not as well -- explored as compact. Here are the laws known today: -- -- -- -- Docs for relationships between these functions and, a cleanup of laws -- will happen at some point. -- -- If you know of more useful laws, or have better names for the ones -- above (especially those marked "name me"). Please let me know. class Compactable (f :: * -> *) compact :: Compactable f => f (Maybe a) -> f a compact :: (Compactable f, Functor f) => f (Maybe a) -> f a separate :: Compactable f => f (Either l r) -> (f l, f r) separate :: (Compactable f, Functor f) => f (Either l r) -> (f l, f r) filter :: Compactable f => (a -> Bool) -> f a -> f a filter :: (Compactable f, Functor f) => (a -> Bool) -> f a -> f a fmapMaybe :: (Compactable f, Functor f) => (a -> Maybe b) -> f a -> f b fmapEither :: (Compactable f, Functor f) => (a -> Either l r) -> f a -> (f l, f r) applyMaybe :: (Compactable f, Applicative f) => f (a -> Maybe b) -> f a -> f b applyEither :: (Compactable f, Applicative f) => f (a -> Either l r) -> f a -> (f l, f r) bindMaybe :: (Compactable f, Monad f) => f a -> (a -> f (Maybe b)) -> f b bindEither :: (Compactable f, Monad f) => f a -> (a -> f (Either l r)) -> (f l, f r) traverseMaybe :: (Compactable f, Applicative g, Traversable f) => (a -> g (Maybe b)) -> f a -> g (f b) traverseEither :: (Compactable f, Applicative g, Traversable f) => (a -> g (Either l r)) -> f a -> g (f l, f r) fforMaybe :: (Compactable f, Functor f) => f a -> (a -> Maybe b) -> f b fforEither :: (Compactable f, Functor f) => f a -> (a -> Either l r) -> (f l, f r) fmapMaybeM :: (Compactable f, Monad f) => (a -> MaybeT f b) -> f a -> f b fmapEitherM :: (Compactable f, Monad f) => (a -> ExceptT l f r) -> f a -> (f l, f r) fforMaybeM :: (Compactable f, Monad f) => f a -> (a -> MaybeT f b) -> f b fforEitherM :: (Compactable f, Monad f) => f a -> (a -> ExceptT l f r) -> (f l, f r) applyMaybeM :: (Compactable f, Monad f) => f (a -> MaybeT f b) -> f a -> f b bindMaybeM :: (Compactable f, Monad f) => f a -> (a -> f (MaybeT f b)) -> f b traverseMaybeM :: (Monad m, Compactable t, Traversable t) => (a -> MaybeT m b) -> t a -> m (t b) -- | While more constrained, when available, this default is going to be -- faster than the one provided in the typeclass altDefaultCompact :: (Alternative f, Monad f) => f (Maybe a) -> f a -- | While more constrained, when available, this default is going to be -- faster than the one provided in the typeclass altDefaultSeparate :: (Alternative f, Foldable f) => f (Either l r) -> (f l, f r) instance Control.Compactable.Compactable GHC.Base.Maybe instance GHC.Base.Monoid m => Control.Compactable.Compactable (Data.Either.Either m) instance Control.Compactable.Compactable [] instance Control.Compactable.Compactable GHC.Types.IO instance Control.Compactable.Compactable GHC.Conc.Sync.STM instance Control.Compactable.Compactable Data.Proxy.Proxy instance Control.Compactable.Compactable Data.Semigroup.Option instance Control.Compactable.Compactable Text.ParserCombinators.ReadP.ReadP instance Control.Compactable.Compactable Text.ParserCombinators.ReadPrec.ReadPrec instance (GHC.Base.Functor f, GHC.Base.Functor g, Control.Compactable.Compactable f, Control.Compactable.Compactable g) => Control.Compactable.Compactable (Data.Functor.Product.Product f g) instance (GHC.Base.Functor f, GHC.Base.Functor g, Control.Compactable.Compactable g) => Control.Compactable.Compactable (Data.Functor.Compose.Compose f g) instance Control.Compactable.Compactable Data.IntMap.Internal.IntMap instance Control.Compactable.Compactable (Data.Map.Internal.Map k) instance Control.Compactable.Compactable Data.Sequence.Internal.Seq instance Control.Compactable.Compactable Data.Vector.Vector instance Control.Compactable.Compactable (Data.Functor.Const.Const r) instance Control.Compactable.Compactable Data.Set.Internal.Set