-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | filterable traversable -- -- A stronger variant of traverse which can remove elements and -- generalised mapMaybe, catMaybes, filter @package witherable @version 0.3.3 module Data.Witherable -- | Like Functor, but you can remove elements instead of updating -- them. -- -- Formally, the class Filterable represents a functor from -- Kleisli Maybe to Hask. -- -- A definition of mapMaybe must satisfy the following laws: -- -- class Functor f => Filterable f -- | Like mapMaybe. mapMaybe :: Filterable f => (a -> Maybe b) -> f a -> f b -- |
--   catMaybesmapMaybe id
--   
catMaybes :: Filterable f => f (Maybe a) -> f a -- |
--   Filterable f . Filterable g ≡ filter (liftA2 (&&) f g)
--   
filter :: Filterable f => (a -> Bool) -> f a -> f a -- | An infix alias for mapMaybe. The name of the operator alludes -- to <$>, and has the same fixity. (<$?>) :: Filterable f => (a -> Maybe b) -> f a -> f b infixl 4 <$?> -- | Flipped version of <$?>, the Filterable version of -- <&>. It has the same fixity as <&>. -- --
--   (<&?>) = flip mapMaybe
--   
(<&?>) :: Filterable f => f a -> (a -> Maybe b) -> f b infixl 1 <&?> -- | An enhancement of Traversable with Filterable -- -- A definition of wither must satisfy the following laws: -- -- -- -- Parametricity implies the naturality law: -- --
--   t . wither f ≡ wither (t . f)
--   
class (Traversable t, Filterable t) => Witherable t -- | Effectful mapMaybe. -- --
--   wither (pure . f) ≡ pure . mapMaybe f
--   
wither :: (Witherable t, Applicative f) => (a -> f (Maybe b)) -> t a -> f (t b) -- |
--   Monadic variant of wither. This may have more efficient implementation.
--   
witherM :: (Witherable t, Monad m) => (a -> m (Maybe b)) -> t a -> m (t b) filterA :: (Witherable t, Applicative f) => (a -> f Bool) -> t a -> f (t a) -- | Removes duplicate elements from a list, keeping only the first -- occurrence. This is asymptotically faster than using nub from -- Data.List. ordNub :: (Witherable t, Ord a) => t a -> t a -- | Removes duplicate elements from a list, keeping only the first -- occurrence. This is usually faster than ordNub, especially for -- things that have a slow comparison (like String). hashNub :: (Witherable t, Eq a, Hashable a) => t a -> t a -- |
--   forMaybe = flip wither
--   
forMaybe :: (Witherable t, Applicative f) => t a -> (a -> f (Maybe b)) -> f (t b) -- | Indexed variant of Filterable. class (FunctorWithIndex i t, Filterable t) => FilterableWithIndex i t | t -> i imapMaybe :: FilterableWithIndex i t => (i -> a -> Maybe b) -> t a -> t b -- |
--   ifilter f . ifilter g ≡ ifilter (i -> liftA2 (&&) (f i) (g i))
--   
ifilter :: FilterableWithIndex i t => (i -> a -> Bool) -> t a -> t a -- | Indexed variant of Witherable. class (TraversableWithIndex i t, Witherable t) => WitherableWithIndex i t | t -> i -- | Effectful imapMaybe. -- --
--   iwither ( i -> pure . f i) ≡ pure . imapMaybe f
--   
iwither :: (WitherableWithIndex i t, Applicative f) => (i -> a -> f (Maybe b)) -> t a -> f (t b) -- |
--   Monadic variant of wither. This may have more efficient implementation.
--   
iwitherM :: (WitherableWithIndex i t, Monad m) => (i -> a -> m (Maybe b)) -> t a -> m (t b) ifilterA :: (WitherableWithIndex i t, Applicative f) => (i -> a -> f Bool) -> t a -> f (t a) -- | This type allows combinators to take a Filter specializing the -- parameter f. type FilterLike f s t a b = (a -> f (Maybe b)) -> s -> f t -- | A Filter is like a Traversal, but you can also remove -- targets. type Filter s t a b = forall f. Applicative f => FilterLike f s t a b -- | A simple FilterLike. type FilterLike' f s a = FilterLike f s s a a -- | A simple Filter. type Filter' s a = forall f. Applicative f => FilterLike' f s a -- | witherOf is actually id, but left for consistency. witherOf :: FilterLike f s t a b -> (a -> f (Maybe b)) -> s -> f t -- |
--   forMaybeOfflip
--   
forMaybeOf :: FilterLike f s t a b -> s -> (a -> f (Maybe b)) -> f t -- | mapMaybe through a filter. mapMaybeOf :: FilterLike Identity s t a b -> (a -> Maybe b) -> s -> t -- | catMaybes through a filter. catMaybesOf :: FilterLike Identity s t (Maybe a) a -> s -> t -- | filterA through a filter. filterAOf :: Functor f => FilterLike' f s a -> (a -> f Bool) -> s -> f s -- | Filter each element of a structure targeted by a Filter. filterOf :: FilterLike' Identity s a -> (a -> Bool) -> s -> s -- | Remove the duplicate elements through a filter. ordNubOf :: Ord a => FilterLike' (State (Set a)) s a -> s -> s -- | Remove the duplicate elements through a filter. It is often faster -- than ordNubOf, especially when the comparison is expensive. hashNubOf :: (Eq a, Hashable a) => FilterLike' (State (HashSet a)) s a -> s -> s -- | Reconstitute a Filter from its monomorphic form. cloneFilter :: FilterLike (Peat a b) s t a b -> Filter s t a b -- | This is used to characterize and clone a Filter. Since -- FilterLike (Peat a b) s t a b is monomorphic, it can be used -- to store a filter in a container. newtype Peat a b t Peat :: (forall f. Applicative f => (a -> f (Maybe b)) -> f t) -> Peat a b t [runPeat] :: Peat a b t -> forall f. Applicative f => (a -> f (Maybe b)) -> f t instance GHC.Base.Alternative f => GHC.Base.Alternative (Data.Witherable.WrappedFoldable f) instance GHC.Base.Applicative f => GHC.Base.Applicative (Data.Witherable.WrappedFoldable f) instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Data.Witherable.WrappedFoldable f) instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Data.Witherable.WrappedFoldable f) instance GHC.Base.Functor f => GHC.Base.Functor (Data.Witherable.WrappedFoldable f) instance Control.Lens.Indexed.FunctorWithIndex i f => Control.Lens.Indexed.FunctorWithIndex i (Data.Witherable.WrappedFoldable f) instance Control.Lens.Indexed.FoldableWithIndex i f => Control.Lens.Indexed.FoldableWithIndex i (Data.Witherable.WrappedFoldable f) instance Control.Lens.Indexed.TraversableWithIndex i f => Control.Lens.Indexed.TraversableWithIndex i (Data.Witherable.WrappedFoldable f) instance (Data.Foldable.Foldable f, GHC.Base.Alternative f) => Data.Witherable.Filterable (Data.Witherable.WrappedFoldable f) instance (Control.Lens.Indexed.FunctorWithIndex i f, Control.Lens.Indexed.FoldableWithIndex i f, GHC.Base.Alternative f) => Data.Witherable.FilterableWithIndex i (Data.Witherable.WrappedFoldable f) instance (GHC.Base.Alternative f, Data.Traversable.Traversable f) => Data.Witherable.Witherable (Data.Witherable.WrappedFoldable f) instance Data.Witherable.WitherableWithIndex () GHC.Maybe.Maybe instance Data.Witherable.WitherableWithIndex GHC.Types.Int [] instance Data.Witherable.WitherableWithIndex GHC.Types.Int Data.IntMap.Internal.IntMap instance Data.Witherable.WitherableWithIndex k (Data.Map.Internal.Map k) instance Data.Witherable.WitherableWithIndex k (Data.Map.Monoidal.MonoidalMap k) instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Data.Witherable.WitherableWithIndex k (Data.HashMap.Base.HashMap k) instance Data.Witherable.WitherableWithIndex Data.Void.Void Data.Proxy.Proxy instance Data.Witherable.WitherableWithIndex GHC.Types.Int Data.Vector.Vector instance Data.Witherable.WitherableWithIndex GHC.Types.Int Data.Sequence.Internal.Seq instance (Control.Lens.Indexed.TraversableWithIndex i f, Data.Witherable.WitherableWithIndex j g) => Data.Witherable.WitherableWithIndex (i, j) (Data.Functor.Compose.Compose f g) instance (Data.Witherable.WitherableWithIndex i f, Data.Witherable.WitherableWithIndex j g) => Data.Witherable.WitherableWithIndex (Data.Either.Either i j) (Data.Functor.Product.Product f g) instance (Data.Witherable.WitherableWithIndex i f, Data.Witherable.WitherableWithIndex j g) => Data.Witherable.WitherableWithIndex (Data.Either.Either i j) (Data.Functor.Sum.Sum f g) instance Data.Witherable.WitherableWithIndex i f => Data.Witherable.WitherableWithIndex i (Control.Monad.Trans.Identity.IdentityT f) instance Data.Witherable.Witherable GHC.Maybe.Maybe instance GHC.Base.Monoid e => Data.Witherable.Witherable (Data.Either.Either e) instance Data.Witherable.Witherable [] instance Data.Witherable.Witherable Data.IntMap.Internal.IntMap instance Data.Witherable.Witherable (Data.Map.Internal.Map k) instance Data.Witherable.Witherable (Data.Map.Monoidal.MonoidalMap k) instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Data.Witherable.Witherable (Data.HashMap.Base.HashMap k) instance Data.Witherable.Witherable Data.Proxy.Proxy instance Data.Witherable.Witherable (Data.Functor.Const.Const r) instance Data.Witherable.Witherable Data.Vector.Vector instance Data.Witherable.Witherable Data.Sequence.Internal.Seq instance (Data.Traversable.Traversable f, Data.Witherable.Witherable g) => Data.Witherable.Witherable (Data.Functor.Compose.Compose f g) instance (Data.Witherable.Witherable f, Data.Witherable.Witherable g) => Data.Witherable.Witherable (Data.Functor.Product.Product f g) instance (Data.Witherable.Witherable f, Data.Witherable.Witherable g) => Data.Witherable.Witherable (Data.Functor.Sum.Sum f g) instance Data.Witherable.Witherable f => Data.Witherable.Witherable (Control.Monad.Trans.Identity.IdentityT f) instance Data.Traversable.Traversable t => Data.Witherable.Witherable (Control.Monad.Trans.Maybe.MaybeT t) instance Data.Witherable.FilterableWithIndex () GHC.Maybe.Maybe instance Data.Witherable.FilterableWithIndex GHC.Types.Int [] instance Data.Witherable.FilterableWithIndex GHC.Types.Int Data.IntMap.Internal.IntMap instance Data.Witherable.FilterableWithIndex k (Data.Map.Internal.Map k) instance Data.Witherable.FilterableWithIndex k (Data.Map.Monoidal.MonoidalMap k) instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Data.Witherable.FilterableWithIndex k (Data.HashMap.Base.HashMap k) instance Data.Witherable.FilterableWithIndex Data.Void.Void Data.Proxy.Proxy instance Data.Witherable.FilterableWithIndex GHC.Types.Int Data.Vector.Vector instance Data.Witherable.FilterableWithIndex GHC.Types.Int Data.Sequence.Internal.Seq instance (Control.Lens.Indexed.FunctorWithIndex i f, Data.Witherable.FilterableWithIndex j g) => Data.Witherable.FilterableWithIndex (i, j) (Data.Functor.Compose.Compose f g) instance (Data.Witherable.FilterableWithIndex i f, Data.Witherable.FilterableWithIndex j g) => Data.Witherable.FilterableWithIndex (Data.Either.Either i j) (Data.Functor.Product.Product f g) instance (Data.Witherable.FilterableWithIndex i f, Data.Witherable.FilterableWithIndex j g) => Data.Witherable.FilterableWithIndex (Data.Either.Either i j) (Data.Functor.Sum.Sum f g) instance Data.Witherable.FilterableWithIndex i f => Data.Witherable.FilterableWithIndex i (Control.Monad.Trans.Identity.IdentityT f) instance Data.Witherable.Filterable GHC.Maybe.Maybe instance GHC.Base.Monoid e => Data.Witherable.Filterable (Data.Either.Either e) instance Data.Witherable.Filterable [] instance Data.Witherable.Filterable Data.IntMap.Internal.IntMap instance Data.Witherable.Filterable (Data.Map.Internal.Map k) instance Data.Witherable.Filterable (Data.Map.Monoidal.MonoidalMap k) instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Data.Witherable.Filterable (Data.HashMap.Base.HashMap k) instance Data.Witherable.Filterable Data.Proxy.Proxy instance Data.Witherable.Filterable (Data.Functor.Const.Const r) instance Data.Witherable.Filterable Data.Vector.Vector instance Data.Witherable.Filterable Data.Sequence.Internal.Seq instance (GHC.Base.Functor f, Data.Witherable.Filterable g) => Data.Witherable.Filterable (Data.Functor.Compose.Compose f g) instance (Data.Witherable.Filterable f, Data.Witherable.Filterable g) => Data.Witherable.Filterable (Data.Functor.Product.Product f g) instance (Data.Witherable.Filterable f, Data.Witherable.Filterable g) => Data.Witherable.Filterable (Data.Functor.Sum.Sum f g) instance Data.Witherable.Filterable f => Data.Witherable.Filterable (Control.Monad.Trans.Identity.IdentityT f) instance GHC.Base.Functor f => Data.Witherable.Filterable (Control.Monad.Trans.Maybe.MaybeT f) instance GHC.Base.Functor (Data.Witherable.Peat a b) instance GHC.Base.Applicative (Data.Witherable.Peat a b)