-- 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 implementations for filter, compact -- (catMaybes), and separate. It allows for higher performance -- implementations to be used in place of defaults for all data -- structures, and endeavors to centerally document those -- implementations. 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.2.0.0 module Control.Functor.Dichotomous -- | Dichotomous is about types that are injective to (Maybe (These a b)) -- In other words a + b + (a * b) + 1. Therefore ab (,) b LeftOnly b ab -- LeftOrBoth a RightOnly a ab RightOrBoth a b Either a b ab These 1 None -- 1 ab MaybeBoth 1 b MaybeRight 1 b ab MaybeRightOrBoth 1 a MaybeLeft 1 -- a ab MaybeLeftOrBoth 1 a b MaybeEither 1 a b ab TheseOrNot class Dichotomous (f :: Type -> Type -> Type) dichotomy :: Dichotomous f => f a b -> Maybe (These a b) ymotohcid :: Dichotomous f => Maybe (These a b) -> Maybe (f a b) hushLeft :: Dichotomous g => g l r -> Maybe r hushRight :: Dichotomous g => g l r -> Maybe l swap :: Dichotomous g => g a b -> Maybe (g b a) newtype AltSum f a AltSum :: f a -> AltSum f a [unAltSum] :: AltSum f a -> f a mfold' :: (Foldable f, Alternative m) => f a -> m a mlefts :: (Bifoldable f, Alternative m) => f a b -> m a mrights :: (Bifoldable f, Alternative m) => f a b -> m b flipThese :: These a b -> These b a newtype LeftOnly a b LeftOnly :: a -> LeftOnly a b [unLeftOnly] :: LeftOnly a b -> a data LeftOrBoth a b Left' :: a -> LeftOrBoth a b LBoth :: a -> b -> LeftOrBoth a b newtype RightOnly a b RightOnly :: b -> RightOnly a b [unRightOnly] :: RightOnly a b -> b data RightOrBoth a b Right' :: b -> RightOrBoth a b RBoth :: a -> b -> RightOrBoth a b -- | The These type represents values with two non-exclusive -- possibilities. -- -- This can be useful to represent combinations of two values, where the -- combination is defined if either input is. Algebraically, the type -- These A B represents (A + B + AB), which -- doesn't factor easily into sums and products--a type like -- Either A (B, Maybe A) is unclear and awkward -- to use. -- -- These has straightforward instances of Functor, -- Monad, &c., and behaves like a hybrid error/writer monad, -- as would be expected. -- -- For zipping and unzipping of structures with These values, see -- Data.Align. data These a b This :: a -> These a b That :: b -> These a b These :: a -> b -> These a b data None a b None :: None a b newtype MaybeBoth a b MaybeBoth :: Maybe (a, b) -> MaybeBoth a b [unMaybeOrBoth] :: MaybeBoth a b -> Maybe (a, b) data MaybeRight a b MRNothing :: MaybeRight a b MRight :: b -> MaybeRight a b data MaybeRightOrBoth a b MRBNothing :: MaybeRightOrBoth a b MRBRight :: b -> MaybeRightOrBoth a b MRBoth :: a -> b -> MaybeRightOrBoth a b data MaybeLeft a b MLNothing :: MaybeLeft a b MLeft :: a -> MaybeLeft a b data MaybeLeftOrBoth a b MLBNothing :: MaybeLeftOrBoth a b MLBLeft :: a -> MaybeLeftOrBoth a b MLBoth :: a -> b -> MaybeLeftOrBoth a b data MaybeEither a b MENothing :: MaybeEither a b MELeft :: a -> MaybeEither a b MERight :: b -> MaybeEither a b data TheseOrNot a b This' :: a -> TheseOrNot a b That' :: b -> TheseOrNot a b These' :: a -> b -> TheseOrNot a b Not :: TheseOrNot a b instance GHC.Generics.Generic (Control.Functor.Dichotomous.LeftOnly a b) instance GHC.Read.Read a => GHC.Read.Read (Control.Functor.Dichotomous.LeftOnly a b) instance GHC.Show.Show a => GHC.Show.Show (Control.Functor.Dichotomous.LeftOnly a b) instance GHC.Classes.Ord a => GHC.Classes.Ord (Control.Functor.Dichotomous.LeftOnly a b) instance GHC.Classes.Eq a => GHC.Classes.Eq (Control.Functor.Dichotomous.LeftOnly a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.LeftOrBoth a b) instance (GHC.Read.Read a, GHC.Read.Read b) => GHC.Read.Read (Control.Functor.Dichotomous.LeftOrBoth a b) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Control.Functor.Dichotomous.LeftOrBoth a b) instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Control.Functor.Dichotomous.LeftOrBoth a b) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Control.Functor.Dichotomous.LeftOrBoth a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.RightOnly a b) instance GHC.Read.Read b => GHC.Read.Read (Control.Functor.Dichotomous.RightOnly a b) instance GHC.Show.Show b => GHC.Show.Show (Control.Functor.Dichotomous.RightOnly a b) instance GHC.Classes.Ord b => GHC.Classes.Ord (Control.Functor.Dichotomous.RightOnly a b) instance GHC.Classes.Eq b => GHC.Classes.Eq (Control.Functor.Dichotomous.RightOnly a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.RightOrBoth a b) instance (GHC.Read.Read b, GHC.Read.Read a) => GHC.Read.Read (Control.Functor.Dichotomous.RightOrBoth a b) instance (GHC.Show.Show b, GHC.Show.Show a) => GHC.Show.Show (Control.Functor.Dichotomous.RightOrBoth a b) instance (GHC.Classes.Ord b, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Functor.Dichotomous.RightOrBoth a b) instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Functor.Dichotomous.RightOrBoth a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.None a b) instance GHC.Read.Read (Control.Functor.Dichotomous.None a b) instance GHC.Show.Show (Control.Functor.Dichotomous.None a b) instance GHC.Classes.Ord (Control.Functor.Dichotomous.None a b) instance GHC.Classes.Eq (Control.Functor.Dichotomous.None a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.MaybeBoth a b) instance (GHC.Read.Read a, GHC.Read.Read b) => GHC.Read.Read (Control.Functor.Dichotomous.MaybeBoth a b) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Control.Functor.Dichotomous.MaybeBoth a b) instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Control.Functor.Dichotomous.MaybeBoth a b) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Control.Functor.Dichotomous.MaybeBoth a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.MaybeRight a b) instance GHC.Read.Read b => GHC.Read.Read (Control.Functor.Dichotomous.MaybeRight a b) instance GHC.Show.Show b => GHC.Show.Show (Control.Functor.Dichotomous.MaybeRight a b) instance GHC.Classes.Ord b => GHC.Classes.Ord (Control.Functor.Dichotomous.MaybeRight a b) instance GHC.Classes.Eq b => GHC.Classes.Eq (Control.Functor.Dichotomous.MaybeRight a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.MaybeRightOrBoth a b) instance (GHC.Read.Read b, GHC.Read.Read a) => GHC.Read.Read (Control.Functor.Dichotomous.MaybeRightOrBoth a b) instance (GHC.Show.Show b, GHC.Show.Show a) => GHC.Show.Show (Control.Functor.Dichotomous.MaybeRightOrBoth a b) instance (GHC.Classes.Ord b, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Functor.Dichotomous.MaybeRightOrBoth a b) instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Functor.Dichotomous.MaybeRightOrBoth a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.MaybeLeft a b) instance GHC.Read.Read a => GHC.Read.Read (Control.Functor.Dichotomous.MaybeLeft a b) instance GHC.Show.Show a => GHC.Show.Show (Control.Functor.Dichotomous.MaybeLeft a b) instance GHC.Classes.Ord a => GHC.Classes.Ord (Control.Functor.Dichotomous.MaybeLeft a b) instance GHC.Classes.Eq a => GHC.Classes.Eq (Control.Functor.Dichotomous.MaybeLeft a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.MaybeLeftOrBoth a b) instance (GHC.Read.Read a, GHC.Read.Read b) => GHC.Read.Read (Control.Functor.Dichotomous.MaybeLeftOrBoth a b) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Control.Functor.Dichotomous.MaybeLeftOrBoth a b) instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Control.Functor.Dichotomous.MaybeLeftOrBoth a b) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Control.Functor.Dichotomous.MaybeLeftOrBoth a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.MaybeEither a b) instance (GHC.Read.Read a, GHC.Read.Read b) => GHC.Read.Read (Control.Functor.Dichotomous.MaybeEither a b) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Control.Functor.Dichotomous.MaybeEither a b) instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Control.Functor.Dichotomous.MaybeEither a b) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Control.Functor.Dichotomous.MaybeEither a b) instance GHC.Generics.Generic (Control.Functor.Dichotomous.TheseOrNot a b) instance (GHC.Read.Read a, GHC.Read.Read b) => GHC.Read.Read (Control.Functor.Dichotomous.TheseOrNot a b) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Control.Functor.Dichotomous.TheseOrNot a b) instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Control.Functor.Dichotomous.TheseOrNot a b) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Control.Functor.Dichotomous.TheseOrNot a b) instance GHC.Base.Alternative f => GHC.Base.Alternative (Control.Functor.Dichotomous.AltSum f) instance GHC.Base.Applicative f => GHC.Base.Applicative (Control.Functor.Dichotomous.AltSum f) instance GHC.Base.Functor f => GHC.Base.Functor (Control.Functor.Dichotomous.AltSum f) instance GHC.Base.Alternative f => GHC.Base.Semigroup (Control.Functor.Dichotomous.AltSum f a) instance GHC.Base.Alternative f => GHC.Base.Monoid (Control.Functor.Dichotomous.AltSum f a) instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.TheseOrNot instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.MaybeEither instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.MaybeLeftOrBoth instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.MaybeLeft instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.MaybeRightOrBoth instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.MaybeRight instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.MaybeBoth instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.None instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.RightOrBoth instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.RightOnly instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.LeftOrBoth instance Control.Functor.Dichotomous.Dichotomous Control.Functor.Dichotomous.LeftOnly instance Control.Functor.Dichotomous.Dichotomous (,) instance Control.Functor.Dichotomous.Dichotomous Data.Either.Either instance Control.Functor.Dichotomous.Dichotomous Data.These.These module Control.Functor.Compactable -- | A generalization of catMaybes -- --
--   compact . map Just = id
--   
-- --
--   compact . mapMaybe id
--   
-- --
--   compact (pure Just <*> a) = a
--   
-- --
--   applyMaybe (pure Just) = id
--   
-- --
--   applyMaybe (pure id) = compact
--   
-- --
--   bindMaybe (return . Just) = id
--   
-- --
--   bindMaybe return = compact
--   
-- --
--   compact (return . Just =<< a) = a
--   
-- --
--   mapMaybe (l <=< r) = mapMaybe l . mapMaybe r
--   
-- --
--   compact (Nothing <$ a) = empty
--   
-- --
--   compact (Nothing <$ a) = mempty
--   
-- --
--   compact empty = empty
--   
-- --
--   compact mempty = mempty
--   
-- --
--   traverseMaybe (Just . Just) = Just
--   
-- --
--   traverseMaybe (map Just . f) = traverse f
--   
class Compactable (f :: Type -> Type) compact :: Compactable f => f (Maybe a) -> f a compact :: (Compactable f, Functor f) => f (Maybe a) -> f a separateThese :: Compactable f => f (These l r) -> (f l, f r) separateThese :: (Compactable f, Functor f) => f (These 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 partition :: Compactable f => (a -> Bool) -> f a -> (f a, f a) partition :: (Compactable f, Functor f) => (a -> Bool) -> f a -> (f a, f a) mapMaybe :: (Compactable f, Functor f) => (a -> Maybe b) -> f a -> f b contramapMaybe :: (Compactable f, Contravariant f) => (Maybe b -> a) -> f a -> f b mapThese :: (Compactable f, Functor f) => (a -> These l r) -> f a -> (f l, f r) contramapThese :: (Compactable f, Contravariant f) => (These l r -> a) -> f a -> (f l, f r) applyMaybe :: (Compactable f, Applicative f) => f (a -> Maybe b) -> f a -> f b applyThese :: (Compactable f, Applicative f) => f (a -> These l r) -> f a -> (f l, f r) bindMaybe :: (Compactable f, Monad f) => (a -> f (Maybe b)) -> f a -> f b bindThese :: (Compactable f, Monad f) => (a -> f (These l r)) -> f a -> (f l, f r) traverseMaybe :: (Compactable f, Applicative g, Traversable f) => (a -> g (Maybe b)) -> f a -> g (f b) traverseThese :: (Compactable f, Applicative g, Traversable f) => (a -> g (These l r)) -> f a -> g (f l, f r) separate :: (Dichotomous g, Functor f, Compactable f) => f (g l r) -> (f l, f r) fforMaybe :: (Compactable f, Functor f) => f a -> (a -> Maybe b) -> f b fforThese :: (Compactable f, Functor f) => f a -> (a -> These l r) -> (f l, f r) mfold' :: (Foldable f, Alternative m) => f a -> m a mlefts :: (Bifoldable f, Alternative m) => f a b -> m a mrights :: (Bifoldable f, Alternative m) => f a b -> m b mapMaybeM :: (Compactable f, Monad f) => (a -> MaybeT f b) -> f a -> f b mapTheseM :: (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 fforTheseM :: (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 :: (Dichotomous d, Alternative f, Foldable f) => f (d l r) -> (f l, f r) instance Control.Functor.Compactable.Compactable GHC.Maybe.Maybe instance GHC.Base.Monoid m => Control.Functor.Compactable.Compactable (Data.Either.Either m) instance GHC.Base.Monoid m => Control.Functor.Compactable.Compactable (Data.These.These m) instance Control.Functor.Compactable.Compactable [] instance Control.Functor.Compactable.Compactable Control.Applicative.ZipList instance Control.Functor.Compactable.Compactable GHC.Types.IO instance Control.Functor.Compactable.Compactable GHC.Conc.Sync.STM instance Control.Functor.Compactable.Compactable Data.Proxy.Proxy instance Control.Functor.Compactable.Compactable GHC.Generics.U1 instance Control.Functor.Compactable.Compactable Data.Semigroup.Option instance (GHC.Base.Functor f, GHC.Base.Functor g, Control.Functor.Compactable.Compactable f, Control.Functor.Compactable.Compactable g) => Control.Functor.Compactable.Compactable (Data.Functor.Product.Product f g) instance (GHC.Base.Functor f, GHC.Base.Functor g, Control.Functor.Compactable.Compactable f, Control.Functor.Compactable.Compactable g) => Control.Functor.Compactable.Compactable (Data.Functor.Compose.Compose f g) instance Control.Functor.Compactable.Compactable Data.IntMap.Internal.IntMap instance Control.Functor.Compactable.Compactable (Data.Map.Internal.Map k) instance Control.Functor.Compactable.Compactable Data.Sequence.Internal.Seq instance Control.Functor.Compactable.Compactable Data.Vector.Vector instance Control.Functor.Compactable.Compactable (Data.Functor.Const.Const r) instance Control.Functor.Compactable.Compactable Data.Set.Internal.Set instance (Control.Functor.Compactable.Compactable a, GHC.Base.Monad a) => Control.Functor.Compactable.Compactable (Control.Applicative.WrappedMonad a) instance (Control.Functor.Compactable.Compactable a, GHC.Base.Functor a) => Control.Functor.Compactable.Compactable (GHC.Generics.Rec1 a) instance (Control.Functor.Compactable.Compactable a, GHC.Base.Functor a) => Control.Functor.Compactable.Compactable (Data.Semigroup.Internal.Alt a) instance (Control.Functor.Compactable.Compactable a, GHC.Base.Functor a, Control.Functor.Compactable.Compactable b, GHC.Base.Functor b) => Control.Functor.Compactable.Compactable (a GHC.Generics.:*: b) instance (Control.Functor.Compactable.Compactable f, GHC.Base.Functor f) => Control.Functor.Compactable.Compactable (GHC.Generics.M1 i c f) instance (GHC.Base.Functor f, Control.Functor.Compactable.Compactable g, GHC.Base.Functor g) => Control.Functor.Compactable.Compactable (f GHC.Generics.:.: g) module Control.Functor.Expansive -- | Partial inverse of Compactable -- --
--   expand (unite x y) = uniteDichotomy x y
--   
-- --
--   unite = emapThese id
--   
-- --
--   map Just = expand
--   
-- --
--   (\x -> unite x x) = map (\x -> These x x)
--   
-- --
--   emapThese f a b = map f (unite a b)
--   
-- --
--   unite (f <$> x) (g <$> y) = bimap f g <$> unite x y
--   
-- --
--   expand (unite x y) = swap <$> unite y x
--   
-- --
--   emapThese f a b = f <$> unite a b
--   
-- --
--   unite empty = map That
--   
-- --
--   flip unite empty = map This
--   
-- --
--   unite mempty = map That
--   
-- --
--   flip unite mempty = map This
--   
class Expansive (f :: Type -> Type) expand :: Expansive f => f a -> f (Maybe a) expand :: (Expansive f, Functor f) => f a -> f (Maybe a) unite :: Expansive f => f l -> f r -> f (These l r) unfilter :: Expansive f => (Bool -> a) -> f a -> f a emapMaybe :: Expansive f => (Maybe b -> a) -> f b -> f a emapMaybe :: (Expansive f, Functor f) => (Maybe b -> a) -> f b -> f a econtramapMaybe :: (Expansive f, Contravariant f) => (a -> Maybe b) -> f b -> f a emapThese :: Expansive f => (These l r -> a) -> f l -> f r -> f a emapThese :: (Expansive f, Functor f) => (These l r -> a) -> f l -> f r -> f a econtramapThese :: (Expansive f, Contravariant f) => (a -> These l r) -> f l -> f r -> f a eapplyMaybe :: (Expansive f, Applicative f) => f (Maybe a -> b) -> f a -> f b eapplyThese :: (Expansive f, Applicative f) => f (These l r -> a) -> f l -> f r -> f a ebindMaybe :: (Expansive f, Applicative f) => (f (Maybe b) -> a) -> f b -> f a ebindThese :: (Expansive f, Applicative f) => (f (These l r) -> a) -> f l -> f r -> f a uniteDichotomy :: (Functor f, Expansive f, Dichotomous g) => f l -> f r -> f (Maybe (g l r)) instance Control.Functor.Expansive.Expansive GHC.Maybe.Maybe instance Control.Functor.Expansive.Expansive [] instance Control.Functor.Expansive.Expansive Control.Applicative.ZipList instance Control.Functor.Expansive.Expansive Data.Proxy.Proxy instance Control.Functor.Expansive.Expansive Data.Semigroup.Option instance Control.Functor.Expansive.Expansive Data.Sequence.Internal.Seq instance GHC.Base.Monad m => Control.Functor.Expansive.Expansive (Data.Vector.Fusion.Bundle.Monadic.Bundle m v) instance GHC.Base.Monad m => Control.Functor.Expansive.Expansive (Data.Vector.Fusion.Stream.Monadic.Stream m) instance Control.Functor.Expansive.Expansive Data.Vector.Vector instance Control.Functor.Expansive.Expansive Data.IntMap.Internal.IntMap instance GHC.Classes.Ord k => Control.Functor.Expansive.Expansive (Data.Map.Internal.Map k) instance (GHC.Base.Functor f, GHC.Base.Functor g, Control.Functor.Expansive.Expansive f, Control.Functor.Expansive.Expansive g) => Control.Functor.Expansive.Expansive (Data.Functor.Product.Product f g) module Control.Functor.Elastic -- | Partial inverse of Compactable -- --
--   expand (unite x y) = uniteDichotomy x y
--   
-- --
--   unite = emapThese id
--   
-- --
--   map Just = expand
--   
-- --
--   (\x -> unite x x) = map (\x -> These x x)
--   
-- --
--   emapThese f a b = map f (unite a b)
--   
-- --
--   unite (f <$> x) (g <$> y) = bimap f g <$> unite x y
--   
-- --
--   expand (unite x y) = swap <$> unite y x
--   
-- --
--   emapThese f a b = f <$> unite a b
--   
-- --
--   unite empty = map That
--   
-- --
--   flip unite empty = map This
--   
-- --
--   unite mempty = map That
--   
-- --
--   flip unite mempty = map This
--   
class Expansive (f :: Type -> Type) -- | A generalization of catMaybes -- --
--   compact . map Just = id
--   
-- --
--   compact . mapMaybe id
--   
-- --
--   compact (pure Just <*> a) = a
--   
-- --
--   applyMaybe (pure Just) = id
--   
-- --
--   applyMaybe (pure id) = compact
--   
-- --
--   bindMaybe (return . Just) = id
--   
-- --
--   bindMaybe return = compact
--   
-- --
--   compact (return . Just =<< a) = a
--   
-- --
--   mapMaybe (l <=< r) = mapMaybe l . mapMaybe r
--   
-- --
--   compact (Nothing <$ a) = empty
--   
-- --
--   compact (Nothing <$ a) = mempty
--   
-- --
--   compact empty = empty
--   
-- --
--   compact mempty = mempty
--   
-- --
--   traverseMaybe (Just . Just) = Just
--   
-- --
--   traverseMaybe (map Just . f) = traverse f
--   
class Compactable (f :: Type -> Type) class (Compactable f, Expansive f) => Elastic f instance Control.Functor.Elastic.Elastic GHC.Maybe.Maybe instance Control.Functor.Elastic.Elastic Data.IntMap.Internal.IntMap instance GHC.Classes.Ord k => Control.Functor.Elastic.Elastic (Data.Map.Internal.Map k)