compactable-0.1.2.4: A typeclass for structures which can be catMaybed, filtered, and partitioned.
Safe HaskellNone
LanguageHaskell2010

Control.Compactable

Synopsis

Compact

class Compactable (f :: * -> *) where Source #

Class Compactable provides two methods which can be writen in terms of each other, compact and separate.

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:

Kleisli composition
fmapMaybe (l <=< r) = fmapMaybe l . fmapMaybe r
Functor identity 1
compact . fmap Just = id
Functor identity 2
fmapMaybe Just = id
Functor relation
compact = fmapMaybe id

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:

Applicative left identity
compact . (pure Just <*>) = id
Applicative right identity
applyMaybe (pure Just) = id
Applicative relation
compact = applyMaybe (pure id)

If the data type is also a Monad the following should hold:

Monad left identity
flip bindMaybe (return . Just) = id
Monad right identity
compact . (return . Just =<<) = id
Monad relation
compact = flip bindMaybe return

If the data type is also Alternative the following should hold:

Alternative identity
compact empty = empty
Alternative annihilation
compact (const Nothing <$> xs) = empty

If the data type is also Traversable the following should hold:

Traversable Applicative relation
traverseMaybe (pure . Just) = pure
Traversable composition
Compose . fmap (traverseMaybe f) . traverseMaybe g = traverseMaybe (Compose . fmap (traverseMaybe f) . g)
Traversable Functor relation
traverse f = traverseMaybe (fmap Just . f)
Traversable naturality
t . traverseMaybe f = traverseMaybe (t . f)

Separate and filter

have recently elevated roles in this typeclass, and is not as well explored as compact. Here are the laws known today:

Functor identity 3
fst . separate . fmap Right = id
Functor identity 4
snd . separate . fmap Left = id
Applicative left identity 2
snd . separate . (pure Right <*>) = id
Applicative right identity 2
fst . separate . (pure Left <*>) = id
Alternative annihilation left
snd . separate . fmap (const Left) = empty
Alternative annihilation right
fst , separate . fmap (const Right) = empty

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.

Minimal complete definition

compact | separate

Methods

compact :: f (Maybe a) -> f a Source #

default compact :: Functor f => f (Maybe a) -> f a Source #

separate :: f (Either l r) -> (f l, f r) Source #

default separate :: Functor f => f (Either l r) -> (f l, f r) Source #

filter :: (a -> Bool) -> f a -> f a Source #

default filter :: Functor f => (a -> Bool) -> f a -> f a Source #

partition :: (a -> Bool) -> f a -> (f a, f a) Source #

default partition :: Functor f => (a -> Bool) -> f a -> (f a, f a) Source #

fmapMaybe :: Functor f => (a -> Maybe b) -> f a -> f b Source #

fmapEither :: Functor f => (a -> Either l r) -> f a -> (f l, f r) Source #

applyMaybe :: Applicative f => f (a -> Maybe b) -> f a -> f b Source #

applyEither :: Applicative f => f (a -> Either l r) -> f a -> (f l, f r) Source #

bindMaybe :: Monad f => f a -> (a -> f (Maybe b)) -> f b Source #

bindEither :: Monad f => f a -> (a -> f (Either l r)) -> (f l, f r) Source #

traverseMaybe :: (Applicative g, Traversable f) => (a -> g (Maybe b)) -> f a -> g (f b) Source #

traverseEither :: (Applicative g, Traversable f) => (a -> g (Either l r)) -> f a -> g (f l, f r) Source #

Instances

Instances details
Compactable [] Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: [Maybe a] -> [a] Source #

separate :: [Either l r] -> ([l], [r]) Source #

filter :: (a -> Bool) -> [a] -> [a] Source #

partition :: (a -> Bool) -> [a] -> ([a], [a]) Source #

fmapMaybe :: Functor [] => (a -> Maybe b) -> [a] -> [b] Source #

fmapEither :: Functor [] => (a -> Either l r) -> [a] -> ([l], [r]) Source #

applyMaybe :: Applicative [] => [a -> Maybe b] -> [a] -> [b] Source #

applyEither :: Applicative [] => [a -> Either l r] -> [a] -> ([l], [r]) Source #

bindMaybe :: Monad [] => [a] -> (a -> [Maybe b]) -> [b] Source #

bindEither :: Monad [] => [a] -> (a -> [Either l r]) -> ([l], [r]) Source #

traverseMaybe :: (Applicative g, Traversable []) => (a -> g (Maybe b)) -> [a] -> g [b] Source #

traverseEither :: (Applicative g, Traversable []) => (a -> g (Either l r)) -> [a] -> g ([l], [r]) Source #

Compactable Maybe Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Maybe (Maybe a) -> Maybe a Source #

separate :: Maybe (Either l r) -> (Maybe l, Maybe r) Source #

filter :: (a -> Bool) -> Maybe a -> Maybe a Source #

partition :: (a -> Bool) -> Maybe a -> (Maybe a, Maybe a) Source #

fmapMaybe :: Functor Maybe => (a -> Maybe b) -> Maybe a -> Maybe b Source #

fmapEither :: Functor Maybe => (a -> Either l r) -> Maybe a -> (Maybe l, Maybe r) Source #

applyMaybe :: Applicative Maybe => Maybe (a -> Maybe b) -> Maybe a -> Maybe b Source #

applyEither :: Applicative Maybe => Maybe (a -> Either l r) -> Maybe a -> (Maybe l, Maybe r) Source #

bindMaybe :: Monad Maybe => Maybe a -> (a -> Maybe (Maybe b)) -> Maybe b Source #

bindEither :: Monad Maybe => Maybe a -> (a -> Maybe (Either l r)) -> (Maybe l, Maybe r) Source #

traverseMaybe :: (Applicative g, Traversable Maybe) => (a -> g (Maybe b)) -> Maybe a -> g (Maybe b) Source #

traverseEither :: (Applicative g, Traversable Maybe) => (a -> g (Either l r)) -> Maybe a -> g (Maybe l, Maybe r) Source #

Compactable IO Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: IO (Maybe a) -> IO a Source #

separate :: IO (Either l r) -> (IO l, IO r) Source #

filter :: (a -> Bool) -> IO a -> IO a Source #

partition :: (a -> Bool) -> IO a -> (IO a, IO a) Source #

fmapMaybe :: Functor IO => (a -> Maybe b) -> IO a -> IO b Source #

fmapEither :: Functor IO => (a -> Either l r) -> IO a -> (IO l, IO r) Source #

applyMaybe :: Applicative IO => IO (a -> Maybe b) -> IO a -> IO b Source #

applyEither :: Applicative IO => IO (a -> Either l r) -> IO a -> (IO l, IO r) Source #

bindMaybe :: Monad IO => IO a -> (a -> IO (Maybe b)) -> IO b Source #

bindEither :: Monad IO => IO a -> (a -> IO (Either l r)) -> (IO l, IO r) Source #

traverseMaybe :: (Applicative g, Traversable IO) => (a -> g (Maybe b)) -> IO a -> g (IO b) Source #

traverseEither :: (Applicative g, Traversable IO) => (a -> g (Either l r)) -> IO a -> g (IO l, IO r) Source #

Compactable Option Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Option (Maybe a) -> Option a Source #

separate :: Option (Either l r) -> (Option l, Option r) Source #

filter :: (a -> Bool) -> Option a -> Option a Source #

partition :: (a -> Bool) -> Option a -> (Option a, Option a) Source #

fmapMaybe :: Functor Option => (a -> Maybe b) -> Option a -> Option b Source #

fmapEither :: Functor Option => (a -> Either l r) -> Option a -> (Option l, Option r) Source #

applyMaybe :: Applicative Option => Option (a -> Maybe b) -> Option a -> Option b Source #

applyEither :: Applicative Option => Option (a -> Either l r) -> Option a -> (Option l, Option r) Source #

bindMaybe :: Monad Option => Option a -> (a -> Option (Maybe b)) -> Option b Source #

bindEither :: Monad Option => Option a -> (a -> Option (Either l r)) -> (Option l, Option r) Source #

traverseMaybe :: (Applicative g, Traversable Option) => (a -> g (Maybe b)) -> Option a -> g (Option b) Source #

traverseEither :: (Applicative g, Traversable Option) => (a -> g (Either l r)) -> Option a -> g (Option l, Option r) Source #

Compactable ZipList Source # 
Instance details

Defined in Control.Compactable

Compactable STM Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: STM (Maybe a) -> STM a Source #

separate :: STM (Either l r) -> (STM l, STM r) Source #

filter :: (a -> Bool) -> STM a -> STM a Source #

partition :: (a -> Bool) -> STM a -> (STM a, STM a) Source #

fmapMaybe :: Functor STM => (a -> Maybe b) -> STM a -> STM b Source #

fmapEither :: Functor STM => (a -> Either l r) -> STM a -> (STM l, STM r) Source #

applyMaybe :: Applicative STM => STM (a -> Maybe b) -> STM a -> STM b Source #

applyEither :: Applicative STM => STM (a -> Either l r) -> STM a -> (STM l, STM r) Source #

bindMaybe :: Monad STM => STM a -> (a -> STM (Maybe b)) -> STM b Source #

bindEither :: Monad STM => STM a -> (a -> STM (Either l r)) -> (STM l, STM r) Source #

traverseMaybe :: (Applicative g, Traversable STM) => (a -> g (Maybe b)) -> STM a -> g (STM b) Source #

traverseEither :: (Applicative g, Traversable STM) => (a -> g (Either l r)) -> STM a -> g (STM l, STM r) Source #

Compactable ReadPrec Source # 
Instance details

Defined in Control.Compactable

Compactable ReadP Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: ReadP (Maybe a) -> ReadP a Source #

separate :: ReadP (Either l r) -> (ReadP l, ReadP r) Source #

filter :: (a -> Bool) -> ReadP a -> ReadP a Source #

partition :: (a -> Bool) -> ReadP a -> (ReadP a, ReadP a) Source #

fmapMaybe :: Functor ReadP => (a -> Maybe b) -> ReadP a -> ReadP b Source #

fmapEither :: Functor ReadP => (a -> Either l r) -> ReadP a -> (ReadP l, ReadP r) Source #

applyMaybe :: Applicative ReadP => ReadP (a -> Maybe b) -> ReadP a -> ReadP b Source #

applyEither :: Applicative ReadP => ReadP (a -> Either l r) -> ReadP a -> (ReadP l, ReadP r) Source #

bindMaybe :: Monad ReadP => ReadP a -> (a -> ReadP (Maybe b)) -> ReadP b Source #

bindEither :: Monad ReadP => ReadP a -> (a -> ReadP (Either l r)) -> (ReadP l, ReadP r) Source #

traverseMaybe :: (Applicative g, Traversable ReadP) => (a -> g (Maybe b)) -> ReadP a -> g (ReadP b) Source #

traverseEither :: (Applicative g, Traversable ReadP) => (a -> g (Either l r)) -> ReadP a -> g (ReadP l, ReadP r) Source #

Compactable IntMap Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: IntMap (Maybe a) -> IntMap a Source #

separate :: IntMap (Either l r) -> (IntMap l, IntMap r) Source #

filter :: (a -> Bool) -> IntMap a -> IntMap a Source #

partition :: (a -> Bool) -> IntMap a -> (IntMap a, IntMap a) Source #

fmapMaybe :: Functor IntMap => (a -> Maybe b) -> IntMap a -> IntMap b Source #

fmapEither :: Functor IntMap => (a -> Either l r) -> IntMap a -> (IntMap l, IntMap r) Source #

applyMaybe :: Applicative IntMap => IntMap (a -> Maybe b) -> IntMap a -> IntMap b Source #

applyEither :: Applicative IntMap => IntMap (a -> Either l r) -> IntMap a -> (IntMap l, IntMap r) Source #

bindMaybe :: Monad IntMap => IntMap a -> (a -> IntMap (Maybe b)) -> IntMap b Source #

bindEither :: Monad IntMap => IntMap a -> (a -> IntMap (Either l r)) -> (IntMap l, IntMap r) Source #

traverseMaybe :: (Applicative g, Traversable IntMap) => (a -> g (Maybe b)) -> IntMap a -> g (IntMap b) Source #

traverseEither :: (Applicative g, Traversable IntMap) => (a -> g (Either l r)) -> IntMap a -> g (IntMap l, IntMap r) Source #

Compactable Seq Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Seq (Maybe a) -> Seq a Source #

separate :: Seq (Either l r) -> (Seq l, Seq r) Source #

filter :: (a -> Bool) -> Seq a -> Seq a Source #

partition :: (a -> Bool) -> Seq a -> (Seq a, Seq a) Source #

fmapMaybe :: Functor Seq => (a -> Maybe b) -> Seq a -> Seq b Source #

fmapEither :: Functor Seq => (a -> Either l r) -> Seq a -> (Seq l, Seq r) Source #

applyMaybe :: Applicative Seq => Seq (a -> Maybe b) -> Seq a -> Seq b Source #

applyEither :: Applicative Seq => Seq (a -> Either l r) -> Seq a -> (Seq l, Seq r) Source #

bindMaybe :: Monad Seq => Seq a -> (a -> Seq (Maybe b)) -> Seq b Source #

bindEither :: Monad Seq => Seq a -> (a -> Seq (Either l r)) -> (Seq l, Seq r) Source #

traverseMaybe :: (Applicative g, Traversable Seq) => (a -> g (Maybe b)) -> Seq a -> g (Seq b) Source #

traverseEither :: (Applicative g, Traversable Seq) => (a -> g (Either l r)) -> Seq a -> g (Seq l, Seq r) Source #

Compactable Set Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Set (Maybe a) -> Set a Source #

separate :: Set (Either l r) -> (Set l, Set r) Source #

filter :: (a -> Bool) -> Set a -> Set a Source #

partition :: (a -> Bool) -> Set a -> (Set a, Set a) Source #

fmapMaybe :: Functor Set => (a -> Maybe b) -> Set a -> Set b Source #

fmapEither :: Functor Set => (a -> Either l r) -> Set a -> (Set l, Set r) Source #

applyMaybe :: Applicative Set => Set (a -> Maybe b) -> Set a -> Set b Source #

applyEither :: Applicative Set => Set (a -> Either l r) -> Set a -> (Set l, Set r) Source #

bindMaybe :: Monad Set => Set a -> (a -> Set (Maybe b)) -> Set b Source #

bindEither :: Monad Set => Set a -> (a -> Set (Either l r)) -> (Set l, Set r) Source #

traverseMaybe :: (Applicative g, Traversable Set) => (a -> g (Maybe b)) -> Set a -> g (Set b) Source #

traverseEither :: (Applicative g, Traversable Set) => (a -> g (Either l r)) -> Set a -> g (Set l, Set r) Source #

Compactable Vector Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Vector (Maybe a) -> Vector a Source #

separate :: Vector (Either l r) -> (Vector l, Vector r) Source #

filter :: (a -> Bool) -> Vector a -> Vector a Source #

partition :: (a -> Bool) -> Vector a -> (Vector a, Vector a) Source #

fmapMaybe :: Functor Vector => (a -> Maybe b) -> Vector a -> Vector b Source #

fmapEither :: Functor Vector => (a -> Either l r) -> Vector a -> (Vector l, Vector r) Source #

applyMaybe :: Applicative Vector => Vector (a -> Maybe b) -> Vector a -> Vector b Source #

applyEither :: Applicative Vector => Vector (a -> Either l r) -> Vector a -> (Vector l, Vector r) Source #

bindMaybe :: Monad Vector => Vector a -> (a -> Vector (Maybe b)) -> Vector b Source #

bindEither :: Monad Vector => Vector a -> (a -> Vector (Either l r)) -> (Vector l, Vector r) Source #

traverseMaybe :: (Applicative g, Traversable Vector) => (a -> g (Maybe b)) -> Vector a -> g (Vector b) Source #

traverseEither :: (Applicative g, Traversable Vector) => (a -> g (Either l r)) -> Vector a -> g (Vector l, Vector r) Source #

Monoid m => Compactable (Either m) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Either m (Maybe a) -> Either m a Source #

separate :: Either m (Either l r) -> (Either m l, Either m r) Source #

filter :: (a -> Bool) -> Either m a -> Either m a Source #

partition :: (a -> Bool) -> Either m a -> (Either m a, Either m a) Source #

fmapMaybe :: Functor (Either m) => (a -> Maybe b) -> Either m a -> Either m b Source #

fmapEither :: Functor (Either m) => (a -> Either l r) -> Either m a -> (Either m l, Either m r) Source #

applyMaybe :: Applicative (Either m) => Either m (a -> Maybe b) -> Either m a -> Either m b Source #

applyEither :: Applicative (Either m) => Either m (a -> Either l r) -> Either m a -> (Either m l, Either m r) Source #

bindMaybe :: Monad (Either m) => Either m a -> (a -> Either m (Maybe b)) -> Either m b Source #

bindEither :: Monad (Either m) => Either m a -> (a -> Either m (Either l r)) -> (Either m l, Either m r) Source #

traverseMaybe :: (Applicative g, Traversable (Either m)) => (a -> g (Maybe b)) -> Either m a -> g (Either m b) Source #

traverseEither :: (Applicative g, Traversable (Either m)) => (a -> g (Either l r)) -> Either m a -> g (Either m l, Either m r) Source #

Compactable (U1 :: Type -> Type) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: U1 (Maybe a) -> U1 a Source #

separate :: U1 (Either l r) -> (U1 l, U1 r) Source #

filter :: (a -> Bool) -> U1 a -> U1 a Source #

partition :: (a -> Bool) -> U1 a -> (U1 a, U1 a) Source #

fmapMaybe :: Functor U1 => (a -> Maybe b) -> U1 a -> U1 b Source #

fmapEither :: Functor U1 => (a -> Either l r) -> U1 a -> (U1 l, U1 r) Source #

applyMaybe :: Applicative U1 => U1 (a -> Maybe b) -> U1 a -> U1 b Source #

applyEither :: Applicative U1 => U1 (a -> Either l r) -> U1 a -> (U1 l, U1 r) Source #

bindMaybe :: Monad U1 => U1 a -> (a -> U1 (Maybe b)) -> U1 b Source #

bindEither :: Monad U1 => U1 a -> (a -> U1 (Either l r)) -> (U1 l, U1 r) Source #

traverseMaybe :: (Applicative g, Traversable U1) => (a -> g (Maybe b)) -> U1 a -> g (U1 b) Source #

traverseEither :: (Applicative g, Traversable U1) => (a -> g (Either l r)) -> U1 a -> g (U1 l, U1 r) Source #

Monad a => Compactable (WrappedMonad a) Source # 
Instance details

Defined in Control.Compactable

(ArrowPlus a, ArrowApply a) => Compactable (ArrowMonad a) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: ArrowMonad a (Maybe a0) -> ArrowMonad a a0 Source #

separate :: ArrowMonad a (Either l r) -> (ArrowMonad a l, ArrowMonad a r) Source #

filter :: (a0 -> Bool) -> ArrowMonad a a0 -> ArrowMonad a a0 Source #

partition :: (a0 -> Bool) -> ArrowMonad a a0 -> (ArrowMonad a a0, ArrowMonad a a0) Source #

fmapMaybe :: Functor (ArrowMonad a) => (a0 -> Maybe b) -> ArrowMonad a a0 -> ArrowMonad a b Source #

fmapEither :: Functor (ArrowMonad a) => (a0 -> Either l r) -> ArrowMonad a a0 -> (ArrowMonad a l, ArrowMonad a r) Source #

applyMaybe :: Applicative (ArrowMonad a) => ArrowMonad a (a0 -> Maybe b) -> ArrowMonad a a0 -> ArrowMonad a b Source #

applyEither :: Applicative (ArrowMonad a) => ArrowMonad a (a0 -> Either l r) -> ArrowMonad a a0 -> (ArrowMonad a l, ArrowMonad a r) Source #

bindMaybe :: Monad (ArrowMonad a) => ArrowMonad a a0 -> (a0 -> ArrowMonad a (Maybe b)) -> ArrowMonad a b Source #

bindEither :: Monad (ArrowMonad a) => ArrowMonad a a0 -> (a0 -> ArrowMonad a (Either l r)) -> (ArrowMonad a l, ArrowMonad a r) Source #

traverseMaybe :: (Applicative g, Traversable (ArrowMonad a)) => (a0 -> g (Maybe b)) -> ArrowMonad a a0 -> g (ArrowMonad a b) Source #

traverseEither :: (Applicative g, Traversable (ArrowMonad a)) => (a0 -> g (Either l r)) -> ArrowMonad a a0 -> g (ArrowMonad a l, ArrowMonad a r) Source #

Compactable (Proxy :: Type -> Type) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Proxy (Maybe a) -> Proxy a Source #

separate :: Proxy (Either l r) -> (Proxy l, Proxy r) Source #

filter :: (a -> Bool) -> Proxy a -> Proxy a Source #

partition :: (a -> Bool) -> Proxy a -> (Proxy a, Proxy a) Source #

fmapMaybe :: Functor Proxy => (a -> Maybe b) -> Proxy a -> Proxy b Source #

fmapEither :: Functor Proxy => (a -> Either l r) -> Proxy a -> (Proxy l, Proxy r) Source #

applyMaybe :: Applicative Proxy => Proxy (a -> Maybe b) -> Proxy a -> Proxy b Source #

applyEither :: Applicative Proxy => Proxy (a -> Either l r) -> Proxy a -> (Proxy l, Proxy r) Source #

bindMaybe :: Monad Proxy => Proxy a -> (a -> Proxy (Maybe b)) -> Proxy b Source #

bindEither :: Monad Proxy => Proxy a -> (a -> Proxy (Either l r)) -> (Proxy l, Proxy r) Source #

traverseMaybe :: (Applicative g, Traversable Proxy) => (a -> g (Maybe b)) -> Proxy a -> g (Proxy b) Source #

traverseEither :: (Applicative g, Traversable Proxy) => (a -> g (Either l r)) -> Proxy a -> g (Proxy l, Proxy r) Source #

Compactable (Map k) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Map k (Maybe a) -> Map k a Source #

separate :: Map k (Either l r) -> (Map k l, Map k r) Source #

filter :: (a -> Bool) -> Map k a -> Map k a Source #

partition :: (a -> Bool) -> Map k a -> (Map k a, Map k a) Source #

fmapMaybe :: Functor (Map k) => (a -> Maybe b) -> Map k a -> Map k b Source #

fmapEither :: Functor (Map k) => (a -> Either l r) -> Map k a -> (Map k l, Map k r) Source #

applyMaybe :: Applicative (Map k) => Map k (a -> Maybe b) -> Map k a -> Map k b Source #

applyEither :: Applicative (Map k) => Map k (a -> Either l r) -> Map k a -> (Map k l, Map k r) Source #

bindMaybe :: Monad (Map k) => Map k a -> (a -> Map k (Maybe b)) -> Map k b Source #

bindEither :: Monad (Map k) => Map k a -> (a -> Map k (Either l r)) -> (Map k l, Map k r) Source #

traverseMaybe :: (Applicative g, Traversable (Map k)) => (a -> g (Maybe b)) -> Map k a -> g (Map k b) Source #

traverseEither :: (Applicative g, Traversable (Map k)) => (a -> g (Either l r)) -> Map k a -> g (Map k l, Map k r) Source #

Functor a => Compactable (Rec1 a) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Rec1 a (Maybe a0) -> Rec1 a a0 Source #

separate :: Rec1 a (Either l r) -> (Rec1 a l, Rec1 a r) Source #

filter :: (a0 -> Bool) -> Rec1 a a0 -> Rec1 a a0 Source #

partition :: (a0 -> Bool) -> Rec1 a a0 -> (Rec1 a a0, Rec1 a a0) Source #

fmapMaybe :: Functor (Rec1 a) => (a0 -> Maybe b) -> Rec1 a a0 -> Rec1 a b Source #

fmapEither :: Functor (Rec1 a) => (a0 -> Either l r) -> Rec1 a a0 -> (Rec1 a l, Rec1 a r) Source #

applyMaybe :: Applicative (Rec1 a) => Rec1 a (a0 -> Maybe b) -> Rec1 a a0 -> Rec1 a b Source #

applyEither :: Applicative (Rec1 a) => Rec1 a (a0 -> Either l r) -> Rec1 a a0 -> (Rec1 a l, Rec1 a r) Source #

bindMaybe :: Monad (Rec1 a) => Rec1 a a0 -> (a0 -> Rec1 a (Maybe b)) -> Rec1 a b Source #

bindEither :: Monad (Rec1 a) => Rec1 a a0 -> (a0 -> Rec1 a (Either l r)) -> (Rec1 a l, Rec1 a r) Source #

traverseMaybe :: (Applicative g, Traversable (Rec1 a)) => (a0 -> g (Maybe b)) -> Rec1 a a0 -> g (Rec1 a b) Source #

traverseEither :: (Applicative g, Traversable (Rec1 a)) => (a0 -> g (Either l r)) -> Rec1 a a0 -> g (Rec1 a l, Rec1 a r) Source #

Compactable (Const r :: Type -> Type) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Const r (Maybe a) -> Const r a Source #

separate :: Const r (Either l r0) -> (Const r l, Const r r0) Source #

filter :: (a -> Bool) -> Const r a -> Const r a Source #

partition :: (a -> Bool) -> Const r a -> (Const r a, Const r a) Source #

fmapMaybe :: Functor (Const r) => (a -> Maybe b) -> Const r a -> Const r b Source #

fmapEither :: Functor (Const r) => (a -> Either l r0) -> Const r a -> (Const r l, Const r r0) Source #

applyMaybe :: Applicative (Const r) => Const r (a -> Maybe b) -> Const r a -> Const r b Source #

applyEither :: Applicative (Const r) => Const r (a -> Either l r0) -> Const r a -> (Const r l, Const r r0) Source #

bindMaybe :: Monad (Const r) => Const r a -> (a -> Const r (Maybe b)) -> Const r b Source #

bindEither :: Monad (Const r) => Const r a -> (a -> Const r (Either l r0)) -> (Const r l, Const r r0) Source #

traverseMaybe :: (Applicative g, Traversable (Const r)) => (a -> g (Maybe b)) -> Const r a -> g (Const r b) Source #

traverseEither :: (Applicative g, Traversable (Const r)) => (a -> g (Either l r0)) -> Const r a -> g (Const r l, Const r r0) Source #

Functor a => Compactable (Alt a) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Alt a (Maybe a0) -> Alt a a0 Source #

separate :: Alt a (Either l r) -> (Alt a l, Alt a r) Source #

filter :: (a0 -> Bool) -> Alt a a0 -> Alt a a0 Source #

partition :: (a0 -> Bool) -> Alt a a0 -> (Alt a a0, Alt a a0) Source #

fmapMaybe :: Functor (Alt a) => (a0 -> Maybe b) -> Alt a a0 -> Alt a b Source #

fmapEither :: Functor (Alt a) => (a0 -> Either l r) -> Alt a a0 -> (Alt a l, Alt a r) Source #

applyMaybe :: Applicative (Alt a) => Alt a (a0 -> Maybe b) -> Alt a a0 -> Alt a b Source #

applyEither :: Applicative (Alt a) => Alt a (a0 -> Either l r) -> Alt a a0 -> (Alt a l, Alt a r) Source #

bindMaybe :: Monad (Alt a) => Alt a a0 -> (a0 -> Alt a (Maybe b)) -> Alt a b Source #

bindEither :: Monad (Alt a) => Alt a a0 -> (a0 -> Alt a (Either l r)) -> (Alt a l, Alt a r) Source #

traverseMaybe :: (Applicative g, Traversable (Alt a)) => (a0 -> g (Maybe b)) -> Alt a a0 -> g (Alt a b) Source #

traverseEither :: (Applicative g, Traversable (Alt a)) => (a0 -> g (Either l r)) -> Alt a a0 -> g (Alt a l, Alt a r) Source #

(Functor a, Functor b) => Compactable (a :*: b) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: (a :*: b) (Maybe a0) -> (a :*: b) a0 Source #

separate :: (a :*: b) (Either l r) -> ((a :*: b) l, (a :*: b) r) Source #

filter :: (a0 -> Bool) -> (a :*: b) a0 -> (a :*: b) a0 Source #

partition :: (a0 -> Bool) -> (a :*: b) a0 -> ((a :*: b) a0, (a :*: b) a0) Source #

fmapMaybe :: Functor (a :*: b) => (a0 -> Maybe b0) -> (a :*: b) a0 -> (a :*: b) b0 Source #

fmapEither :: Functor (a :*: b) => (a0 -> Either l r) -> (a :*: b) a0 -> ((a :*: b) l, (a :*: b) r) Source #

applyMaybe :: Applicative (a :*: b) => (a :*: b) (a0 -> Maybe b0) -> (a :*: b) a0 -> (a :*: b) b0 Source #

applyEither :: Applicative (a :*: b) => (a :*: b) (a0 -> Either l r) -> (a :*: b) a0 -> ((a :*: b) l, (a :*: b) r) Source #

bindMaybe :: Monad (a :*: b) => (a :*: b) a0 -> (a0 -> (a :*: b) (Maybe b0)) -> (a :*: b) b0 Source #

bindEither :: Monad (a :*: b) => (a :*: b) a0 -> (a0 -> (a :*: b) (Either l r)) -> ((a :*: b) l, (a :*: b) r) Source #

traverseMaybe :: (Applicative g, Traversable (a :*: b)) => (a0 -> g (Maybe b0)) -> (a :*: b) a0 -> g ((a :*: b) b0) Source #

traverseEither :: (Applicative g, Traversable (a :*: b)) => (a0 -> g (Either l r)) -> (a :*: b) a0 -> g ((a :*: b) l, (a :*: b) r) Source #

(Functor f, Functor g, Compactable f, Compactable g) => Compactable (Product f g) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Product f g (Maybe a) -> Product f g a Source #

separate :: Product f g (Either l r) -> (Product f g l, Product f g r) Source #

filter :: (a -> Bool) -> Product f g a -> Product f g a Source #

partition :: (a -> Bool) -> Product f g a -> (Product f g a, Product f g a) Source #

fmapMaybe :: Functor (Product f g) => (a -> Maybe b) -> Product f g a -> Product f g b Source #

fmapEither :: Functor (Product f g) => (a -> Either l r) -> Product f g a -> (Product f g l, Product f g r) Source #

applyMaybe :: Applicative (Product f g) => Product f g (a -> Maybe b) -> Product f g a -> Product f g b Source #

applyEither :: Applicative (Product f g) => Product f g (a -> Either l r) -> Product f g a -> (Product f g l, Product f g r) Source #

bindMaybe :: Monad (Product f g) => Product f g a -> (a -> Product f g (Maybe b)) -> Product f g b Source #

bindEither :: Monad (Product f g) => Product f g a -> (a -> Product f g (Either l r)) -> (Product f g l, Product f g r) Source #

traverseMaybe :: (Applicative g0, Traversable (Product f g)) => (a -> g0 (Maybe b)) -> Product f g a -> g0 (Product f g b) Source #

traverseEither :: (Applicative g0, Traversable (Product f g)) => (a -> g0 (Either l r)) -> Product f g a -> g0 (Product f g l, Product f g r) Source #

Functor f => Compactable (M1 i c f) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: M1 i c f (Maybe a) -> M1 i c f a Source #

separate :: M1 i c f (Either l r) -> (M1 i c f l, M1 i c f r) Source #

filter :: (a -> Bool) -> M1 i c f a -> M1 i c f a Source #

partition :: (a -> Bool) -> M1 i c f a -> (M1 i c f a, M1 i c f a) Source #

fmapMaybe :: Functor (M1 i c f) => (a -> Maybe b) -> M1 i c f a -> M1 i c f b Source #

fmapEither :: Functor (M1 i c f) => (a -> Either l r) -> M1 i c f a -> (M1 i c f l, M1 i c f r) Source #

applyMaybe :: Applicative (M1 i c f) => M1 i c f (a -> Maybe b) -> M1 i c f a -> M1 i c f b Source #

applyEither :: Applicative (M1 i c f) => M1 i c f (a -> Either l r) -> M1 i c f a -> (M1 i c f l, M1 i c f r) Source #

bindMaybe :: Monad (M1 i c f) => M1 i c f a -> (a -> M1 i c f (Maybe b)) -> M1 i c f b Source #

bindEither :: Monad (M1 i c f) => M1 i c f a -> (a -> M1 i c f (Either l r)) -> (M1 i c f l, M1 i c f r) Source #

traverseMaybe :: (Applicative g, Traversable (M1 i c f)) => (a -> g (Maybe b)) -> M1 i c f a -> g (M1 i c f b) Source #

traverseEither :: (Applicative g, Traversable (M1 i c f)) => (a -> g (Either l r)) -> M1 i c f a -> g (M1 i c f l, M1 i c f r) Source #

(Functor f, Functor g) => Compactable (f :.: g) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: (f :.: g) (Maybe a) -> (f :.: g) a Source #

separate :: (f :.: g) (Either l r) -> ((f :.: g) l, (f :.: g) r) Source #

filter :: (a -> Bool) -> (f :.: g) a -> (f :.: g) a Source #

partition :: (a -> Bool) -> (f :.: g) a -> ((f :.: g) a, (f :.: g) a) Source #

fmapMaybe :: Functor (f :.: g) => (a -> Maybe b) -> (f :.: g) a -> (f :.: g) b Source #

fmapEither :: Functor (f :.: g) => (a -> Either l r) -> (f :.: g) a -> ((f :.: g) l, (f :.: g) r) Source #

applyMaybe :: Applicative (f :.: g) => (f :.: g) (a -> Maybe b) -> (f :.: g) a -> (f :.: g) b Source #

applyEither :: Applicative (f :.: g) => (f :.: g) (a -> Either l r) -> (f :.: g) a -> ((f :.: g) l, (f :.: g) r) Source #

bindMaybe :: Monad (f :.: g) => (f :.: g) a -> (a -> (f :.: g) (Maybe b)) -> (f :.: g) b Source #

bindEither :: Monad (f :.: g) => (f :.: g) a -> (a -> (f :.: g) (Either l r)) -> ((f :.: g) l, (f :.: g) r) Source #

traverseMaybe :: (Applicative g0, Traversable (f :.: g)) => (a -> g0 (Maybe b)) -> (f :.: g) a -> g0 ((f :.: g) b) Source #

traverseEither :: (Applicative g0, Traversable (f :.: g)) => (a -> g0 (Either l r)) -> (f :.: g) a -> g0 ((f :.: g) l, (f :.: g) r) Source #

(Functor f, Functor g, Compactable g) => Compactable (Compose f g) Source # 
Instance details

Defined in Control.Compactable

Methods

compact :: Compose f g (Maybe a) -> Compose f g a Source #

separate :: Compose f g (Either l r) -> (Compose f g l, Compose f g r) Source #

filter :: (a -> Bool) -> Compose f g a -> Compose f g a Source #

partition :: (a -> Bool) -> Compose f g a -> (Compose f g a, Compose f g a) Source #

fmapMaybe :: Functor (Compose f g) => (a -> Maybe b) -> Compose f g a -> Compose f g b Source #

fmapEither :: Functor (Compose f g) => (a -> Either l r) -> Compose f g a -> (Compose f g l, Compose f g r) Source #

applyMaybe :: Applicative (Compose f g) => Compose f g (a -> Maybe b) -> Compose f g a -> Compose f g b Source #

applyEither :: Applicative (Compose f g) => Compose f g (a -> Either l r) -> Compose f g a -> (Compose f g l, Compose f g r) Source #

bindMaybe :: Monad (Compose f g) => Compose f g a -> (a -> Compose f g (Maybe b)) -> Compose f g b Source #

bindEither :: Monad (Compose f g) => Compose f g a -> (a -> Compose f g (Either l r)) -> (Compose f g l, Compose f g r) Source #

traverseMaybe :: (Applicative g0, Traversable (Compose f g)) => (a -> g0 (Maybe b)) -> Compose f g a -> g0 (Compose f g b) Source #

traverseEither :: (Applicative g0, Traversable (Compose f g)) => (a -> g0 (Either l r)) -> Compose f g a -> g0 (Compose f g l, Compose f g r) Source #

Compact Fold

class Compactable f => CompactFold (f :: * -> *) where Source #

class CompactFold provides the same methods as Compactable but generalized to work on any Foldable.

When a type has Alternative (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.

Minimal complete definition

Nothing

Methods

compactFold :: Foldable g => f (g a) -> f a Source #

default compactFold :: (Monad f, Alternative f, Foldable g) => f (g a) -> f a Source #

separateFold :: Bifoldable g => f (g a b) -> (f a, f b) Source #

default separateFold :: (Monad f, Alternative f, Bifoldable g) => f (g a b) -> (f a, f b) Source #

fmapFold :: (Functor f, Foldable g) => (a -> g b) -> f a -> f b Source #

fmapBifold :: (Functor f, Bifoldable g) => (a -> g l r) -> f a -> (f l, f r) Source #

applyFold :: (Applicative f, Foldable g) => f (a -> g b) -> f a -> f b Source #

applyBifold :: (Applicative f, Bifoldable g) => f (a -> g l r) -> f a -> (f l, f r) Source #

bindFold :: (Monad f, Foldable g) => f a -> (a -> f (g b)) -> f b Source #

bindBifold :: (Monad f, Bifoldable g) => f a -> (a -> f (g l r)) -> (f l, f r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable f) => (a -> h (g b)) -> f a -> h (f b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable f) => (a -> h (g l r)) -> f a -> h (f l, f r) Source #

Instances

Instances details
CompactFold [] Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => [g a] -> [a] Source #

separateFold :: Bifoldable g => [g a b] -> ([a], [b]) Source #

fmapFold :: (Functor [], Foldable g) => (a -> g b) -> [a] -> [b] Source #

fmapBifold :: (Functor [], Bifoldable g) => (a -> g l r) -> [a] -> ([l], [r]) Source #

applyFold :: (Applicative [], Foldable g) => [a -> g b] -> [a] -> [b] Source #

applyBifold :: (Applicative [], Bifoldable g) => [a -> g l r] -> [a] -> ([l], [r]) Source #

bindFold :: (Monad [], Foldable g) => [a] -> (a -> [g b]) -> [b] Source #

bindBifold :: (Monad [], Bifoldable g) => [a] -> (a -> [g l r]) -> ([l], [r]) Source #

traverseFold :: (Applicative h, Foldable g, Traversable []) => (a -> h (g b)) -> [a] -> h [b] Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable []) => (a -> h (g l r)) -> [a] -> h ([l], [r]) Source #

CompactFold Maybe Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => Maybe (g a) -> Maybe a Source #

separateFold :: Bifoldable g => Maybe (g a b) -> (Maybe a, Maybe b) Source #

fmapFold :: (Functor Maybe, Foldable g) => (a -> g b) -> Maybe a -> Maybe b Source #

fmapBifold :: (Functor Maybe, Bifoldable g) => (a -> g l r) -> Maybe a -> (Maybe l, Maybe r) Source #

applyFold :: (Applicative Maybe, Foldable g) => Maybe (a -> g b) -> Maybe a -> Maybe b Source #

applyBifold :: (Applicative Maybe, Bifoldable g) => Maybe (a -> g l r) -> Maybe a -> (Maybe l, Maybe r) Source #

bindFold :: (Monad Maybe, Foldable g) => Maybe a -> (a -> Maybe (g b)) -> Maybe b Source #

bindBifold :: (Monad Maybe, Bifoldable g) => Maybe a -> (a -> Maybe (g l r)) -> (Maybe l, Maybe r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable Maybe) => (a -> h (g b)) -> Maybe a -> h (Maybe b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable Maybe) => (a -> h (g l r)) -> Maybe a -> h (Maybe l, Maybe r) Source #

CompactFold IO Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => IO (g a) -> IO a Source #

separateFold :: Bifoldable g => IO (g a b) -> (IO a, IO b) Source #

fmapFold :: (Functor IO, Foldable g) => (a -> g b) -> IO a -> IO b Source #

fmapBifold :: (Functor IO, Bifoldable g) => (a -> g l r) -> IO a -> (IO l, IO r) Source #

applyFold :: (Applicative IO, Foldable g) => IO (a -> g b) -> IO a -> IO b Source #

applyBifold :: (Applicative IO, Bifoldable g) => IO (a -> g l r) -> IO a -> (IO l, IO r) Source #

bindFold :: (Monad IO, Foldable g) => IO a -> (a -> IO (g b)) -> IO b Source #

bindBifold :: (Monad IO, Bifoldable g) => IO a -> (a -> IO (g l r)) -> (IO l, IO r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable IO) => (a -> h (g b)) -> IO a -> h (IO b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable IO) => (a -> h (g l r)) -> IO a -> h (IO l, IO r) Source #

CompactFold Option Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => Option (g a) -> Option a Source #

separateFold :: Bifoldable g => Option (g a b) -> (Option a, Option b) Source #

fmapFold :: (Functor Option, Foldable g) => (a -> g b) -> Option a -> Option b Source #

fmapBifold :: (Functor Option, Bifoldable g) => (a -> g l r) -> Option a -> (Option l, Option r) Source #

applyFold :: (Applicative Option, Foldable g) => Option (a -> g b) -> Option a -> Option b Source #

applyBifold :: (Applicative Option, Bifoldable g) => Option (a -> g l r) -> Option a -> (Option l, Option r) Source #

bindFold :: (Monad Option, Foldable g) => Option a -> (a -> Option (g b)) -> Option b Source #

bindBifold :: (Monad Option, Bifoldable g) => Option a -> (a -> Option (g l r)) -> (Option l, Option r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable Option) => (a -> h (g b)) -> Option a -> h (Option b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable Option) => (a -> h (g l r)) -> Option a -> h (Option l, Option r) Source #

CompactFold ZipList Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => ZipList (g a) -> ZipList a Source #

separateFold :: Bifoldable g => ZipList (g a b) -> (ZipList a, ZipList b) Source #

fmapFold :: (Functor ZipList, Foldable g) => (a -> g b) -> ZipList a -> ZipList b Source #

fmapBifold :: (Functor ZipList, Bifoldable g) => (a -> g l r) -> ZipList a -> (ZipList l, ZipList r) Source #

applyFold :: (Applicative ZipList, Foldable g) => ZipList (a -> g b) -> ZipList a -> ZipList b Source #

applyBifold :: (Applicative ZipList, Bifoldable g) => ZipList (a -> g l r) -> ZipList a -> (ZipList l, ZipList r) Source #

bindFold :: (Monad ZipList, Foldable g) => ZipList a -> (a -> ZipList (g b)) -> ZipList b Source #

bindBifold :: (Monad ZipList, Bifoldable g) => ZipList a -> (a -> ZipList (g l r)) -> (ZipList l, ZipList r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable ZipList) => (a -> h (g b)) -> ZipList a -> h (ZipList b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable ZipList) => (a -> h (g l r)) -> ZipList a -> h (ZipList l, ZipList r) Source #

CompactFold STM Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => STM (g a) -> STM a Source #

separateFold :: Bifoldable g => STM (g a b) -> (STM a, STM b) Source #

fmapFold :: (Functor STM, Foldable g) => (a -> g b) -> STM a -> STM b Source #

fmapBifold :: (Functor STM, Bifoldable g) => (a -> g l r) -> STM a -> (STM l, STM r) Source #

applyFold :: (Applicative STM, Foldable g) => STM (a -> g b) -> STM a -> STM b Source #

applyBifold :: (Applicative STM, Bifoldable g) => STM (a -> g l r) -> STM a -> (STM l, STM r) Source #

bindFold :: (Monad STM, Foldable g) => STM a -> (a -> STM (g b)) -> STM b Source #

bindBifold :: (Monad STM, Bifoldable g) => STM a -> (a -> STM (g l r)) -> (STM l, STM r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable STM) => (a -> h (g b)) -> STM a -> h (STM b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable STM) => (a -> h (g l r)) -> STM a -> h (STM l, STM r) Source #

CompactFold ReadPrec Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => ReadPrec (g a) -> ReadPrec a Source #

separateFold :: Bifoldable g => ReadPrec (g a b) -> (ReadPrec a, ReadPrec b) Source #

fmapFold :: (Functor ReadPrec, Foldable g) => (a -> g b) -> ReadPrec a -> ReadPrec b Source #

fmapBifold :: (Functor ReadPrec, Bifoldable g) => (a -> g l r) -> ReadPrec a -> (ReadPrec l, ReadPrec r) Source #

applyFold :: (Applicative ReadPrec, Foldable g) => ReadPrec (a -> g b) -> ReadPrec a -> ReadPrec b Source #

applyBifold :: (Applicative ReadPrec, Bifoldable g) => ReadPrec (a -> g l r) -> ReadPrec a -> (ReadPrec l, ReadPrec r) Source #

bindFold :: (Monad ReadPrec, Foldable g) => ReadPrec a -> (a -> ReadPrec (g b)) -> ReadPrec b Source #

bindBifold :: (Monad ReadPrec, Bifoldable g) => ReadPrec a -> (a -> ReadPrec (g l r)) -> (ReadPrec l, ReadPrec r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable ReadPrec) => (a -> h (g b)) -> ReadPrec a -> h (ReadPrec b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable ReadPrec) => (a -> h (g l r)) -> ReadPrec a -> h (ReadPrec l, ReadPrec r) Source #

CompactFold ReadP Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => ReadP (g a) -> ReadP a Source #

separateFold :: Bifoldable g => ReadP (g a b) -> (ReadP a, ReadP b) Source #

fmapFold :: (Functor ReadP, Foldable g) => (a -> g b) -> ReadP a -> ReadP b Source #

fmapBifold :: (Functor ReadP, Bifoldable g) => (a -> g l r) -> ReadP a -> (ReadP l, ReadP r) Source #

applyFold :: (Applicative ReadP, Foldable g) => ReadP (a -> g b) -> ReadP a -> ReadP b Source #

applyBifold :: (Applicative ReadP, Bifoldable g) => ReadP (a -> g l r) -> ReadP a -> (ReadP l, ReadP r) Source #

bindFold :: (Monad ReadP, Foldable g) => ReadP a -> (a -> ReadP (g b)) -> ReadP b Source #

bindBifold :: (Monad ReadP, Bifoldable g) => ReadP a -> (a -> ReadP (g l r)) -> (ReadP l, ReadP r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable ReadP) => (a -> h (g b)) -> ReadP a -> h (ReadP b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable ReadP) => (a -> h (g l r)) -> ReadP a -> h (ReadP l, ReadP r) Source #

CompactFold (U1 :: Type -> Type) Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => U1 (g a) -> U1 a Source #

separateFold :: Bifoldable g => U1 (g a b) -> (U1 a, U1 b) Source #

fmapFold :: (Functor U1, Foldable g) => (a -> g b) -> U1 a -> U1 b Source #

fmapBifold :: (Functor U1, Bifoldable g) => (a -> g l r) -> U1 a -> (U1 l, U1 r) Source #

applyFold :: (Applicative U1, Foldable g) => U1 (a -> g b) -> U1 a -> U1 b Source #

applyBifold :: (Applicative U1, Bifoldable g) => U1 (a -> g l r) -> U1 a -> (U1 l, U1 r) Source #

bindFold :: (Monad U1, Foldable g) => U1 a -> (a -> U1 (g b)) -> U1 b Source #

bindBifold :: (Monad U1, Bifoldable g) => U1 a -> (a -> U1 (g l r)) -> (U1 l, U1 r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable U1) => (a -> h (g b)) -> U1 a -> h (U1 b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable U1) => (a -> h (g l r)) -> U1 a -> h (U1 l, U1 r) Source #

MonadPlus a => CompactFold (WrappedMonad a) Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => WrappedMonad a (g a0) -> WrappedMonad a a0 Source #

separateFold :: Bifoldable g => WrappedMonad a (g a0 b) -> (WrappedMonad a a0, WrappedMonad a b) Source #

fmapFold :: (Functor (WrappedMonad a), Foldable g) => (a0 -> g b) -> WrappedMonad a a0 -> WrappedMonad a b Source #

fmapBifold :: (Functor (WrappedMonad a), Bifoldable g) => (a0 -> g l r) -> WrappedMonad a a0 -> (WrappedMonad a l, WrappedMonad a r) Source #

applyFold :: (Applicative (WrappedMonad a), Foldable g) => WrappedMonad a (a0 -> g b) -> WrappedMonad a a0 -> WrappedMonad a b Source #

applyBifold :: (Applicative (WrappedMonad a), Bifoldable g) => WrappedMonad a (a0 -> g l r) -> WrappedMonad a a0 -> (WrappedMonad a l, WrappedMonad a r) Source #

bindFold :: (Monad (WrappedMonad a), Foldable g) => WrappedMonad a a0 -> (a0 -> WrappedMonad a (g b)) -> WrappedMonad a b Source #

bindBifold :: (Monad (WrappedMonad a), Bifoldable g) => WrappedMonad a a0 -> (a0 -> WrappedMonad a (g l r)) -> (WrappedMonad a l, WrappedMonad a r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable (WrappedMonad a)) => (a0 -> h (g b)) -> WrappedMonad a a0 -> h (WrappedMonad a b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable (WrappedMonad a)) => (a0 -> h (g l r)) -> WrappedMonad a a0 -> h (WrappedMonad a l, WrappedMonad a r) Source #

(ArrowPlus a, ArrowApply a) => CompactFold (ArrowMonad a) Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => ArrowMonad a (g a0) -> ArrowMonad a a0 Source #

separateFold :: Bifoldable g => ArrowMonad a (g a0 b) -> (ArrowMonad a a0, ArrowMonad a b) Source #

fmapFold :: (Functor (ArrowMonad a), Foldable g) => (a0 -> g b) -> ArrowMonad a a0 -> ArrowMonad a b Source #

fmapBifold :: (Functor (ArrowMonad a), Bifoldable g) => (a0 -> g l r) -> ArrowMonad a a0 -> (ArrowMonad a l, ArrowMonad a r) Source #

applyFold :: (Applicative (ArrowMonad a), Foldable g) => ArrowMonad a (a0 -> g b) -> ArrowMonad a a0 -> ArrowMonad a b Source #

applyBifold :: (Applicative (ArrowMonad a), Bifoldable g) => ArrowMonad a (a0 -> g l r) -> ArrowMonad a a0 -> (ArrowMonad a l, ArrowMonad a r) Source #

bindFold :: (Monad (ArrowMonad a), Foldable g) => ArrowMonad a a0 -> (a0 -> ArrowMonad a (g b)) -> ArrowMonad a b Source #

bindBifold :: (Monad (ArrowMonad a), Bifoldable g) => ArrowMonad a a0 -> (a0 -> ArrowMonad a (g l r)) -> (ArrowMonad a l, ArrowMonad a r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable (ArrowMonad a)) => (a0 -> h (g b)) -> ArrowMonad a a0 -> h (ArrowMonad a b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable (ArrowMonad a)) => (a0 -> h (g l r)) -> ArrowMonad a a0 -> h (ArrowMonad a l, ArrowMonad a r) Source #

CompactFold (Proxy :: Type -> Type) Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => Proxy (g a) -> Proxy a Source #

separateFold :: Bifoldable g => Proxy (g a b) -> (Proxy a, Proxy b) Source #

fmapFold :: (Functor Proxy, Foldable g) => (a -> g b) -> Proxy a -> Proxy b Source #

fmapBifold :: (Functor Proxy, Bifoldable g) => (a -> g l r) -> Proxy a -> (Proxy l, Proxy r) Source #

applyFold :: (Applicative Proxy, Foldable g) => Proxy (a -> g b) -> Proxy a -> Proxy b Source #

applyBifold :: (Applicative Proxy, Bifoldable g) => Proxy (a -> g l r) -> Proxy a -> (Proxy l, Proxy r) Source #

bindFold :: (Monad Proxy, Foldable g) => Proxy a -> (a -> Proxy (g b)) -> Proxy b Source #

bindBifold :: (Monad Proxy, Bifoldable g) => Proxy a -> (a -> Proxy (g l r)) -> (Proxy l, Proxy r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable Proxy) => (a -> h (g b)) -> Proxy a -> h (Proxy b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable Proxy) => (a -> h (g l r)) -> Proxy a -> h (Proxy l, Proxy r) Source #

(Alternative a, Monad a) => CompactFold (Rec1 a) Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => Rec1 a (g a0) -> Rec1 a a0 Source #

separateFold :: Bifoldable g => Rec1 a (g a0 b) -> (Rec1 a a0, Rec1 a b) Source #

fmapFold :: (Functor (Rec1 a), Foldable g) => (a0 -> g b) -> Rec1 a a0 -> Rec1 a b Source #

fmapBifold :: (Functor (Rec1 a), Bifoldable g) => (a0 -> g l r) -> Rec1 a a0 -> (Rec1 a l, Rec1 a r) Source #

applyFold :: (Applicative (Rec1 a), Foldable g) => Rec1 a (a0 -> g b) -> Rec1 a a0 -> Rec1 a b Source #

applyBifold :: (Applicative (Rec1 a), Bifoldable g) => Rec1 a (a0 -> g l r) -> Rec1 a a0 -> (Rec1 a l, Rec1 a r) Source #

bindFold :: (Monad (Rec1 a), Foldable g) => Rec1 a a0 -> (a0 -> Rec1 a (g b)) -> Rec1 a b Source #

bindBifold :: (Monad (Rec1 a), Bifoldable g) => Rec1 a a0 -> (a0 -> Rec1 a (g l r)) -> (Rec1 a l, Rec1 a r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable (Rec1 a)) => (a0 -> h (g b)) -> Rec1 a a0 -> h (Rec1 a b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable (Rec1 a)) => (a0 -> h (g l r)) -> Rec1 a a0 -> h (Rec1 a l, Rec1 a r) Source #

(Alternative a, Monad a) => CompactFold (Alt a) Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => Alt a (g a0) -> Alt a a0 Source #

separateFold :: Bifoldable g => Alt a (g a0 b) -> (Alt a a0, Alt a b) Source #

fmapFold :: (Functor (Alt a), Foldable g) => (a0 -> g b) -> Alt a a0 -> Alt a b Source #

fmapBifold :: (Functor (Alt a), Bifoldable g) => (a0 -> g l r) -> Alt a a0 -> (Alt a l, Alt a r) Source #

applyFold :: (Applicative (Alt a), Foldable g) => Alt a (a0 -> g b) -> Alt a a0 -> Alt a b Source #

applyBifold :: (Applicative (Alt a), Bifoldable g) => Alt a (a0 -> g l r) -> Alt a a0 -> (Alt a l, Alt a r) Source #

bindFold :: (Monad (Alt a), Foldable g) => Alt a a0 -> (a0 -> Alt a (g b)) -> Alt a b Source #

bindBifold :: (Monad (Alt a), Bifoldable g) => Alt a a0 -> (a0 -> Alt a (g l r)) -> (Alt a l, Alt a r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable (Alt a)) => (a0 -> h (g b)) -> Alt a a0 -> h (Alt a b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable (Alt a)) => (a0 -> h (g l r)) -> Alt a a0 -> h (Alt a l, Alt a r) Source #

(Alternative f, Monad f, Alternative g, Monad g) => CompactFold (f :*: g) Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g0 => (f :*: g) (g0 a) -> (f :*: g) a Source #

separateFold :: Bifoldable g0 => (f :*: g) (g0 a b) -> ((f :*: g) a, (f :*: g) b) Source #

fmapFold :: (Functor (f :*: g), Foldable g0) => (a -> g0 b) -> (f :*: g) a -> (f :*: g) b Source #

fmapBifold :: (Functor (f :*: g), Bifoldable g0) => (a -> g0 l r) -> (f :*: g) a -> ((f :*: g) l, (f :*: g) r) Source #

applyFold :: (Applicative (f :*: g), Foldable g0) => (f :*: g) (a -> g0 b) -> (f :*: g) a -> (f :*: g) b Source #

applyBifold :: (Applicative (f :*: g), Bifoldable g0) => (f :*: g) (a -> g0 l r) -> (f :*: g) a -> ((f :*: g) l, (f :*: g) r) Source #

bindFold :: (Monad (f :*: g), Foldable g0) => (f :*: g) a -> (a -> (f :*: g) (g0 b)) -> (f :*: g) b Source #

bindBifold :: (Monad (f :*: g), Bifoldable g0) => (f :*: g) a -> (a -> (f :*: g) (g0 l r)) -> ((f :*: g) l, (f :*: g) r) Source #

traverseFold :: (Applicative h, Foldable g0, Traversable (f :*: g)) => (a -> h (g0 b)) -> (f :*: g) a -> h ((f :*: g) b) Source #

traverseBifold :: (Applicative h, Bifoldable g0, Traversable (f :*: g)) => (a -> h (g0 l r)) -> (f :*: g) a -> h ((f :*: g) l, (f :*: g) r) Source #

(Compactable f, Alternative f, Monad f, Compactable g, Alternative g, Monad g) => CompactFold (Product f g) Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g0 => Product f g (g0 a) -> Product f g a Source #

separateFold :: Bifoldable g0 => Product f g (g0 a b) -> (Product f g a, Product f g b) Source #

fmapFold :: (Functor (Product f g), Foldable g0) => (a -> g0 b) -> Product f g a -> Product f g b Source #

fmapBifold :: (Functor (Product f g), Bifoldable g0) => (a -> g0 l r) -> Product f g a -> (Product f g l, Product f g r) Source #

applyFold :: (Applicative (Product f g), Foldable g0) => Product f g (a -> g0 b) -> Product f g a -> Product f g b Source #

applyBifold :: (Applicative (Product f g), Bifoldable g0) => Product f g (a -> g0 l r) -> Product f g a -> (Product f g l, Product f g r) Source #

bindFold :: (Monad (Product f g), Foldable g0) => Product f g a -> (a -> Product f g (g0 b)) -> Product f g b Source #

bindBifold :: (Monad (Product f g), Bifoldable g0) => Product f g a -> (a -> Product f g (g0 l r)) -> (Product f g l, Product f g r) Source #

traverseFold :: (Applicative h, Foldable g0, Traversable (Product f g)) => (a -> h (g0 b)) -> Product f g a -> h (Product f g b) Source #

traverseBifold :: (Applicative h, Bifoldable g0, Traversable (Product f g)) => (a -> h (g0 l r)) -> Product f g a -> h (Product f g l, Product f g r) Source #

(Alternative f, Monad f) => CompactFold (M1 i c f) Source # 
Instance details

Defined in Control.Compactable

Methods

compactFold :: Foldable g => M1 i c f (g a) -> M1 i c f a Source #

separateFold :: Bifoldable g => M1 i c f (g a b) -> (M1 i c f a, M1 i c f b) Source #

fmapFold :: (Functor (M1 i c f), Foldable g) => (a -> g b) -> M1 i c f a -> M1 i c f b Source #

fmapBifold :: (Functor (M1 i c f), Bifoldable g) => (a -> g l r) -> M1 i c f a -> (M1 i c f l, M1 i c f r) Source #

applyFold :: (Applicative (M1 i c f), Foldable g) => M1 i c f (a -> g b) -> M1 i c f a -> M1 i c f b Source #

applyBifold :: (Applicative (M1 i c f), Bifoldable g) => M1 i c f (a -> g l r) -> M1 i c f a -> (M1 i c f l, M1 i c f r) Source #

bindFold :: (Monad (M1 i c f), Foldable g) => M1 i c f a -> (a -> M1 i c f (g b)) -> M1 i c f b Source #

bindBifold :: (Monad (M1 i c f), Bifoldable g) => M1 i c f a -> (a -> M1 i c f (g l r)) -> (M1 i c f l, M1 i c f r) Source #

traverseFold :: (Applicative h, Foldable g, Traversable (M1 i c f)) => (a -> h (g b)) -> M1 i c f a -> h (M1 i c f b) Source #

traverseBifold :: (Applicative h, Bifoldable g, Traversable (M1 i c f)) => (a -> h (g l r)) -> M1 i c f a -> h (M1 i c f l, M1 i c f r) Source #

Handly flips

fforMaybe :: (Compactable f, Functor f) => f a -> (a -> Maybe b) -> f b Source #

fforFold :: (CompactFold f, Functor f, Foldable g) => f a -> (a -> g b) -> f b Source #

fforEither :: (Compactable f, Functor f) => f a -> (a -> Either l r) -> (f l, f r) Source #

fforBifold :: (CompactFold f, Functor f, Bifoldable g) => f a -> (a -> g l r) -> (f l, f r) Source #

More general lefts and rights

mfold' :: (Foldable f, Alternative m) => f a -> m a Source #

mlefts :: (Bifoldable f, Alternative m) => f a b -> m a Source #

mrights :: (Bifoldable f, Alternative m) => f a b -> m b Source #

Monad Transformer utils

fmapMaybeM :: (Compactable f, Monad f) => (a -> MaybeT f b) -> f a -> f b Source #

fmapEitherM :: (Compactable f, Monad f) => (a -> ExceptT l f r) -> f a -> (f l, f r) Source #

fforMaybeM :: (Compactable f, Monad f) => f a -> (a -> MaybeT f b) -> f b Source #

fforEitherM :: (Compactable f, Monad f) => f a -> (a -> ExceptT l f r) -> (f l, f r) Source #

applyMaybeM :: (Compactable f, Monad f) => f (a -> MaybeT f b) -> f a -> f b Source #

bindMaybeM :: (Compactable f, Monad f) => f a -> (a -> f (MaybeT f b)) -> f b Source #

traverseMaybeM :: (Monad m, Compactable t, Traversable t) => (a -> MaybeT m b) -> t a -> m (t b) Source #

Alternative Defaults

altDefaultCompact :: (Alternative f, Monad f) => f (Maybe a) -> f a Source #

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) Source #

While more constrained, when available, this default is going to be faster than the one provided in the typeclass