-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Combinators for operating with selections over an underlying functor -- -- Combinators for operating with selections over an underlying functor @package selections @version 0.1.0.2 module Data.Functor.Selection -- | The simplest selection type newtype Selection f b a Selection :: f (Either b a) -> Selection f b a -- | Expose the underlying representation of a Selection [runSelection] :: Selection f b a -> f (Either b a) -- | Create a selection from a functor by selecting all values newSelection :: (Selectable s f) => f a -> s b a -- | Drops selection from your functor returning all values (selected or -- not). -- --
-- forgetSelection . newSelection = id ---- --
-- forgetSelection = unify id id --forgetSelection :: (Selectable s f) => s a a -> f a -- | Clear the selection then select only items which match a predicate. -- --
-- select f = include f . deselectAll --select :: (Selectable s f) => (a -> Bool) -> s a a -> s a a -- | Add items which match a predicate to the current selection -- --
-- include f . select g = select (a -> f a || g a) --include :: (Selectable s f) => (a -> Bool) -> s a a -> s a a -- | Remove items which match a predicate to the current selection -- --
-- exclude f . select g = select (a -> f a && not (g a)) --exclude :: (Selectable s f) => (a -> Bool) -> s a a -> s a a -- | Select all items in the container -- --
-- selectAll = include (const True) --selectAll :: (Selectable s f) => s a a -> s a a -- | Deselect all items in the container -- --
-- deselectAll = exclude (const True) --deselectAll :: (Selectable s f) => s a a -> s a a -- | Flip the selection, all selected are now unselected and vice versa. invertSelection :: (Selectable s f) => s b a -> s a b -- | Map over selected values -- --
-- onSelected = fmap --mapSelected :: (Selectable s f) => (a -> c) -> s b a -> s b c -- | Map over unselected values -- --
-- onSelected f = modifySelection (fmap (first f)) --mapUnselected :: (Selectable s f) => (b -> c) -> s b a -> s c a -- | Collect all selected values into a list. For more complex operations -- use foldMap. -- --
-- getSelected = foldMap (:[]) --getSelected :: (Selectable s f, Foldable f) => s b a -> [a] -- | Collect all unselected values into a list. For more complex operations -- use operations from Bifoldable. -- --
-- getUnselected = getSelected . invertSelection --getUnselected :: (Selectable s f, Foldable f) => s b a -> [b] -- | Unify selected and unselected and forget the selection -- --
-- unify f g == forgetSelection . onUnselected f . onSelected g --unify :: (Selectable s f) => (b -> c) -> (a -> c) -> s b a -> f c -- | Perform a natural transformation over the underlying container of a -- selectable trans :: (Selectable s f, Selectable t g) => (forall c. f c -> g c) -> s b a -> t b a -- | Select values based on their context within a comonad. This combinator -- makes its selection by running the predicate using extend. selectWithContext :: (Selectable s w, Comonad w) => (w a -> Bool) -> s a a -> s a a instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Data.Functor.Selection.Selection f b) instance GHC.Base.Functor f => GHC.Base.Functor (Data.Functor.Selection.Selection f b) instance GHC.Show.Show (f (Data.Either.Either b a)) => GHC.Show.Show (Data.Functor.Selection.Selection f b a) instance GHC.Classes.Eq (f (Data.Either.Either b a)) => GHC.Classes.Eq (Data.Functor.Selection.Selection f b a) instance GHC.Base.Monad m => GHC.Base.Applicative (Data.Functor.Selection.Selection m b) instance GHC.Base.Monad m => GHC.Base.Monad (Data.Functor.Selection.Selection m b) instance GHC.Base.Functor f => Data.Bifunctor.Bifunctor (Data.Functor.Selection.Selection f) instance Data.Foldable.Foldable f => Data.Bifoldable.Bifoldable (Data.Functor.Selection.Selection f) instance Data.Traversable.Traversable f => Data.Bitraversable.Bitraversable (Data.Functor.Selection.Selection f) instance GHC.Base.Functor f => Data.Functor.Selection.Selectable (Data.Functor.Selection.Selection f) f