-- 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.5 module 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 -- |
--   filter f . filter g ≡ filter (liftA2 (&&) g f)
--   
filter :: Filterable f => (a -> Bool) -> f a -> f a -- | Empty a filterable. -- --
--   drainmapMaybe (const Nothing)
--   
drain :: Filterable f => f a -> f b -- | 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: -- -- -- -- In the relation to superclasses, these should satisfy too: -- -- -- -- See the Properties.md and Laws.md files in the git -- distribution for more in-depth explanation about properties of -- Witherable containers. -- -- The laws and restrictions are enough to constrain -- wither to be uniquely determined as the following -- default implementation. -- --
--   wither f = fmap catMaybes . traverse f
--   
-- -- If not to provide better-performing implementation, it's not necessary -- to implement any one method of Witherable. For example, if a -- type constructor T already has instances of -- Traversable and Filterable, the next one line is -- sufficient to provide the Witherable T instance. -- --
--   instance Witherable T
--   
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) witherMap :: (Witherable t, Applicative m) => (t b -> r) -> (a -> m (Maybe b)) -> t a -> m r -- | Removes duplicate elements from a list, keeping only the first -- occurrence. This is asymptotically faster than using nub from -- Data.List. -- --
--   >>> ordNub [3,2,1,3,2,1]
--   [3,2,1]
--   
ordNub :: (Witherable t, Ord a) => t a -> t a -- | The ordNubOn function behaves just like ordNub, except -- it uses a another type to determine equivalence classes. -- --
--   >>> ordNubOn fst [(True, 'x'), (False, 'y'), (True, 'z')]
--   [(True,'x'),(False,'y')]
--   
ordNubOn :: (Witherable t, Ord b) => (a -> b) -> 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 [3,2,1,3,2,1]
--   [3,2,1]
--   
hashNub :: (Witherable t, Eq a, Hashable a) => t a -> t a -- | The hashNubOn function behaves just like hashNub, except -- it uses a another type to determine equivalence classes. -- --
--   >>> hashNubOn fst [(True, 'x'), (False, 'y'), (True, 'z')]
--   [(True,'x'),(False,'y')]
--   
hashNubOn :: (Witherable t, Eq b, Hashable b) => (a -> b) -> 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 -- |
--   filter f . ifilter g ≡ ifilter (i x -> f x && g i x)
--   
ifilter :: FilterableWithIndex i t => (i -> a -> Bool) -> t a -> t a -- | Indexed variant of Witherable. class (TraversableWithIndex i t, FilterableWithIndex 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) newtype WrappedFoldable f a WrapFilterable :: f a -> WrappedFoldable f a [unwrapFoldable] :: WrappedFoldable f a -> f a instance GHC.Base.Functor Witherable.BoolPair instance GHC.Base.Alternative f => GHC.Base.Alternative (Witherable.WrappedFoldable f) instance GHC.Base.Applicative f => GHC.Base.Applicative (Witherable.WrappedFoldable f) instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Witherable.WrappedFoldable f) instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Witherable.WrappedFoldable f) instance GHC.Base.Functor f => GHC.Base.Functor (Witherable.WrappedFoldable f) instance Witherable.Filterable f => Witherable.Filterable (Control.Monad.Trans.Identity.IdentityT f) instance Witherable.Filterable t => Witherable.Filterable (Data.Functor.Reverse.Reverse t) instance Witherable.Filterable t => Witherable.Filterable (Control.Applicative.Backwards.Backwards t) instance Witherable.FilterableWithIndex i f => Witherable.FilterableWithIndex i (Control.Monad.Trans.Identity.IdentityT f) instance Witherable.FilterableWithIndex i t => Witherable.FilterableWithIndex i (Data.Functor.Reverse.Reverse t) instance Witherable.FilterableWithIndex i t => Witherable.FilterableWithIndex i (Control.Applicative.Backwards.Backwards t) instance WithIndex.FunctorWithIndex i f => WithIndex.FunctorWithIndex i (Witherable.WrappedFoldable f) instance WithIndex.FoldableWithIndex i f => WithIndex.FoldableWithIndex i (Witherable.WrappedFoldable f) instance WithIndex.TraversableWithIndex i f => WithIndex.TraversableWithIndex i (Witherable.WrappedFoldable f) instance (Data.Foldable.Foldable f, GHC.Base.Alternative f) => Witherable.Filterable (Witherable.WrappedFoldable f) instance (WithIndex.FunctorWithIndex i f, WithIndex.FoldableWithIndex i f, GHC.Base.Alternative f) => Witherable.FilterableWithIndex i (Witherable.WrappedFoldable f) instance (GHC.Base.Alternative f, Data.Traversable.Traversable f) => Witherable.Witherable (Witherable.WrappedFoldable f) instance Witherable.WitherableWithIndex () GHC.Maybe.Maybe instance Witherable.WitherableWithIndex GHC.Types.Int [] instance Witherable.WitherableWithIndex GHC.Types.Int Control.Applicative.ZipList instance Witherable.WitherableWithIndex GHC.Types.Int Data.IntMap.Internal.IntMap instance Witherable.WitherableWithIndex k (Data.Map.Internal.Map k) instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Witherable.WitherableWithIndex k (Data.HashMap.Internal.HashMap k) instance Witherable.WitherableWithIndex GHC.Base.Void Data.Proxy.Proxy instance Witherable.WitherableWithIndex GHC.Types.Int Data.Vector.Vector instance Witherable.WitherableWithIndex GHC.Types.Int Data.Sequence.Internal.Seq instance (WithIndex.TraversableWithIndex i f, Witherable.WitherableWithIndex j g) => Witherable.WitherableWithIndex (i, j) (Data.Functor.Compose.Compose f g) instance (Witherable.WitherableWithIndex i f, Witherable.WitherableWithIndex j g) => Witherable.WitherableWithIndex (Data.Either.Either i j) (Data.Functor.Product.Product f g) instance (Witherable.WitherableWithIndex i f, Witherable.WitherableWithIndex j g) => Witherable.WitherableWithIndex (Data.Either.Either i j) (Data.Functor.Sum.Sum f g) instance Witherable.WitherableWithIndex i f => Witherable.WitherableWithIndex i (Control.Monad.Trans.Identity.IdentityT f) instance Witherable.WitherableWithIndex i t => Witherable.WitherableWithIndex i (Data.Functor.Reverse.Reverse t) instance Witherable.WitherableWithIndex i t => Witherable.WitherableWithIndex i (Control.Applicative.Backwards.Backwards t) instance Witherable.FilterableWithIndex () GHC.Maybe.Maybe instance Witherable.FilterableWithIndex GHC.Types.Int [] instance Witherable.FilterableWithIndex GHC.Types.Int Control.Applicative.ZipList instance Witherable.FilterableWithIndex GHC.Types.Int Data.IntMap.Internal.IntMap instance Witherable.FilterableWithIndex k (Data.Map.Internal.Map k) instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Witherable.FilterableWithIndex k (Data.HashMap.Internal.HashMap k) instance Witherable.FilterableWithIndex GHC.Base.Void Data.Proxy.Proxy instance Witherable.FilterableWithIndex GHC.Types.Int Data.Vector.Vector instance Witherable.FilterableWithIndex GHC.Types.Int Data.Sequence.Internal.Seq instance (WithIndex.FunctorWithIndex i f, Witherable.FilterableWithIndex j g) => Witherable.FilterableWithIndex (i, j) (Data.Functor.Compose.Compose f g) instance (Witherable.FilterableWithIndex i f, Witherable.FilterableWithIndex j g) => Witherable.FilterableWithIndex (Data.Either.Either i j) (Data.Functor.Product.Product f g) instance (Witherable.FilterableWithIndex i f, Witherable.FilterableWithIndex j g) => Witherable.FilterableWithIndex (Data.Either.Either i j) (Data.Functor.Sum.Sum f g) instance Witherable.Witherable GHC.Maybe.Maybe instance GHC.Base.Monoid e => Witherable.Witherable (Data.Either.Either e) instance Witherable.Witherable [] instance Witherable.Witherable Control.Applicative.ZipList instance Witherable.Witherable Data.IntMap.Internal.IntMap instance Witherable.Witherable (Data.Map.Internal.Map k) instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Witherable.Witherable (Data.HashMap.Internal.HashMap k) instance Witherable.Witherable Data.Proxy.Proxy instance Witherable.Witherable (Data.Functor.Const.Const r) instance Witherable.Witherable Data.Vector.Vector instance Witherable.Witherable Data.Sequence.Internal.Seq instance (Data.Traversable.Traversable f, Witherable.Witherable g) => Witherable.Witherable (Data.Functor.Compose.Compose f g) instance (Witherable.Witherable f, Witherable.Witherable g) => Witherable.Witherable (Data.Functor.Product.Product f g) instance (Witherable.Witherable f, Witherable.Witherable g) => Witherable.Witherable (Data.Functor.Sum.Sum f g) instance Witherable.Witherable f => Witherable.Witherable (Control.Monad.Trans.Identity.IdentityT f) instance Data.Traversable.Traversable t => Witherable.Witherable (Control.Monad.Trans.Maybe.MaybeT t) instance Witherable.Witherable t => Witherable.Witherable (Data.Functor.Reverse.Reverse t) instance Witherable.Witherable t => Witherable.Witherable (Control.Applicative.Backwards.Backwards t) instance Witherable.Witherable GHC.Generics.V1 instance Witherable.Witherable GHC.Generics.U1 instance Witherable.Witherable (GHC.Generics.K1 i c) instance Witherable.Witherable f => Witherable.Witherable (GHC.Generics.Rec1 f) instance Witherable.Witherable f => Witherable.Witherable (GHC.Generics.M1 i c f) instance (Witherable.Witherable f, Witherable.Witherable g) => Witherable.Witherable (f GHC.Generics.:*: g) instance (Witherable.Witherable f, Witherable.Witherable g) => Witherable.Witherable (f GHC.Generics.:+: g) instance (Data.Traversable.Traversable f, Witherable.Witherable g) => Witherable.Witherable (f GHC.Generics.:.: g) instance Witherable.Filterable GHC.Maybe.Maybe instance GHC.Base.Monoid e => Witherable.Filterable (Data.Either.Either e) instance Witherable.Filterable [] instance Witherable.Filterable Control.Applicative.ZipList instance Witherable.Filterable Data.IntMap.Internal.IntMap instance Witherable.Filterable (Data.Map.Internal.Map k) instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Witherable.Filterable (Data.HashMap.Internal.HashMap k) instance Witherable.Filterable Data.Proxy.Proxy instance Witherable.Filterable (Data.Functor.Const.Const r) instance Witherable.Filterable Data.Vector.Vector instance Witherable.Filterable Data.Sequence.Internal.Seq instance (GHC.Base.Functor f, Witherable.Filterable g) => Witherable.Filterable (Data.Functor.Compose.Compose f g) instance (Witherable.Filterable f, Witherable.Filterable g) => Witherable.Filterable (Data.Functor.Product.Product f g) instance (Witherable.Filterable f, Witherable.Filterable g) => Witherable.Filterable (Data.Functor.Sum.Sum f g) instance GHC.Base.Functor f => Witherable.Filterable (Control.Monad.Trans.Maybe.MaybeT f) instance Witherable.Filterable GHC.Generics.V1 instance Witherable.Filterable GHC.Generics.U1 instance Witherable.Filterable (GHC.Generics.K1 i c) instance Witherable.Filterable f => Witherable.Filterable (GHC.Generics.Rec1 f) instance Witherable.Filterable f => Witherable.Filterable (GHC.Generics.M1 i c f) instance (Witherable.Filterable f, Witherable.Filterable g) => Witherable.Filterable (f GHC.Generics.:*: g) instance (Witherable.Filterable f, Witherable.Filterable g) => Witherable.Filterable (f GHC.Generics.:+: g) instance (GHC.Base.Functor f, Witherable.Filterable g) => Witherable.Filterable (f GHC.Generics.:.: g)