-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Class of filtrable containers
--   
--   See <a>Data.Filtrable</a>.
@package filtrable
@version 0.1.6.0


-- | See <a>Filtrable</a>.
module Data.Filtrable

-- | Class of filtrable containers, i.e. containers we can map over while
--   selectively dropping elements.
--   
--   Laws:
--   
--   <ul>
--   <li><pre><a>mapMaybe</a> <a>Just</a> = id</pre></li>
--   <li><pre><a>mapMaybe</a> f = <a>catMaybes</a> ∘ <a>fmap</a>
--   f</pre></li>
--   <li><pre><a>catMaybes</a> = <a>mapMaybe</a> id</pre></li>
--   <li><pre><a>filter</a> f = <a>mapMaybe</a> (\ x -&gt; <a>bool</a>
--   <a>Nothing</a> (<a>Just</a> x) (f x))</pre></li>
--   <li><pre><a>mapMaybe</a> g . <a>mapMaybe</a> f = <a>mapMaybe</a> (g
--   <a>&lt;=&lt;</a> f)</pre></li>
--   </ul>
--   
--   Laws if <tt><a>Foldable</a> f</tt>:
--   
--   <ul>
--   <li><pre><a>foldMap</a> g . <a>filter</a> f = <a>foldMap</a> (\ x
--   -&gt; <a>bool</a> <a>mempty</a> (g x) (f x))</pre></li>
--   </ul>
class Functor f => Filtrable (f :: Type -> Type)

-- | Map the container with the given function, dropping the elements for
--   which it returns <a>Nothing</a>.
mapMaybe :: Filtrable f => (a -> Maybe b) -> f a -> f b

-- | <pre>
--   <a>catMaybes</a> = <a>mapMaybe</a> <a>id</a>
--   </pre>
catMaybes :: Filtrable f => f (Maybe a) -> f a

-- | Drop the elements for which the given predicate is <a>False</a>.
filter :: Filtrable f => (a -> Bool) -> f a -> f a

-- | Traverse the container with the given function, dropping the elements
--   for which it returns <a>Nothing</a>.
mapMaybeA :: (Filtrable f, Traversable f, Applicative p) => (a -> p (Maybe b)) -> f a -> p (f b)

-- | Drop the elements for which the given predicate is <a>False</a>.
filterA :: (Filtrable f, Traversable f, Applicative p) => (a -> p Bool) -> f a -> p (f a)

-- | Map the container with the given function, collecting the <a>Left</a>s
--   and the <a>Right</a>s separately.
mapEither :: Filtrable f => (a -> Either b c) -> f a -> (f b, f c)

-- | Traverse the container with the given function, collecting the
--   <a>Left</a>s and the <a>Right</a>s separately.
mapEitherA :: (Filtrable f, Traversable f, Applicative p) => (a -> p (Either b c)) -> f a -> p (f b, f c)

-- | <pre>
--   <a>partitionEithers</a> = <a>mapEither</a> <a>id</a>
--   </pre>
partitionEithers :: Filtrable f => f (Either a b) -> (f a, f b)

-- | Infix synonym of <a>mapMaybe</a>
(<$?>) :: Filtrable f => (a -> Maybe b) -> f a -> f b
infixl 4 <$?>

-- | <pre>
--   f <a>&lt;*?&gt;</a> a = <a>catMaybes</a> (f <a>&lt;*&gt;</a> a)
--   </pre>
(<*?>) :: (Applicative p, Filtrable p) => p (a -> Maybe b) -> p a -> p b
infixl 4 <*?>

-- | &lt;math&gt; Delete all but the first copy of each element, special
--   case of <a>nubBy</a>.
nub :: (Filtrable f, Traversable f, Eq a) => f a -> f a

-- | &lt;math&gt; Delete all but the first copy of each element, with the
--   given relation.
nubBy :: (Filtrable f, Traversable f) => (a -> a -> Bool) -> f a -> f a

-- | &lt;math&gt; Delete all but the first copy of each element, special
--   case of <a>nubOrdBy</a>.
nubOrd :: (Filtrable f, Traversable f, Ord a) => f a -> f a

-- | &lt;math&gt; Delete all but the first copy of each element, with the
--   given relation.
nubOrdBy :: (Filtrable f, Traversable f) => (a -> a -> Ordering) -> f a -> f a
instance Data.Filtrable.Filtrable f => Data.Filtrable.Filtrable (Control.Applicative.Backwards.Backwards f)
instance (GHC.Internal.Base.Functor f, Data.Filtrable.Filtrable g) => Data.Filtrable.Filtrable (Data.Functor.Compose.Compose f g)
instance Data.Filtrable.Filtrable (GHC.Internal.Data.Functor.Const.Const a)
instance Data.Filtrable.Filtrable Data.IntMap.Internal.IntMap
instance Data.Filtrable.Filtrable []
instance GHC.Classes.Ord k => Data.Filtrable.Filtrable (Data.Map.Internal.Map k)
instance Data.Filtrable.Filtrable GHC.Internal.Maybe.Maybe
instance (Data.Filtrable.Filtrable f, Data.Filtrable.Filtrable g) => Data.Filtrable.Filtrable (Data.Functor.Product.Product f g)
instance Data.Filtrable.Filtrable GHC.Internal.Data.Proxy.Proxy
instance Data.Filtrable.Filtrable f => Data.Filtrable.Filtrable (Data.Functor.Reverse.Reverse f)
instance Data.Filtrable.Filtrable Data.Sequence.Internal.Seq
instance (Data.Filtrable.Filtrable f, Data.Filtrable.Filtrable g) => Data.Filtrable.Filtrable (Data.Functor.Sum.Sum f g)
