-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Combinators for operating with selections over an underlying functor -- -- See the README on github for tutorials! @package selections @version 0.2.0.0 module Data.Functor.Selection -- | A selection wraps a Functor f and has an unselected type -- b and a selected type a newtype Selection f b a Selection :: f (Either b a) -> Selection f b a -- | Expose the underlying representation of a Selection [unwrapSelection] :: Selection f b a -> f (Either b a) -- | A type alias for selections with the same unselected/selected types type Selection' f a = Selection f a a -- | Modify the underlying representation of a selection modifySelection :: (Functor f) => (f (Either b a) -> g (Either d c)) -> Selection f b a -> Selection g d c -- | Create a selection from a functor by selecting all values newSelection :: (Functor f) => f a -> Selection f b a -- | Drops selection from your functor returning all values (selected or -- not). -- --
--   forgetSelection . newSelection = id
--   
-- --
--   forgetSelection = unify id id
--   
forgetSelection :: (Functor f) => Selection f a a -> f a -- | Clear the selection then select only items which match a predicate. -- --
--   select f = include f . deselectAll
--   
select :: (Functor f) => (a -> Bool) -> Selection f a a -> Selection f a a -- | Add items which match a predicate to the current selection -- --
--   include f . select g = select (a -> f a || g a)
--   
include :: (Functor f) => (a -> Bool) -> Selection f a a -> Selection f a a -- | Remove items which match a predicate to the current selection -- --
--   exclude f . select g = select (a -> f a && not (g a))
--   
exclude :: (Functor f) => (a -> Bool) -> Selection f a a -> Selection f a a -- | Select all items in the container -- --
--   selectAll = include (const True)
--   
selectAll :: (Functor f) => Selection f a a -> Selection f a a -- | Deselect all items in the container -- --
--   deselectAll = exclude (const True)
--   
deselectAll :: (Functor f) => Selection f a a -> Selection f a a -- | Flip the selection, all selected are now unselected and vice versa. invertSelection :: (Functor f) => Selection f b a -> Selection f a b -- | Map over selected values -- --
--   mapSelected = fmap
--   
mapSelected :: (Functor f) => (a -> c) -> Selection f b a -> Selection f b c -- | Map over unselected values -- --
--   mapUnselected = first
--   
mapUnselected :: (Functor f) => (b -> c) -> Selection f b a -> Selection f c a -- | Collect all selected values into a list. For more complex operations -- use foldMap. -- --
--   getSelected = foldMap (:[])
--   
getSelected :: (Foldable f) => Selection f b a -> [a] -- | Collect all unselected values into a list. For more complex operations -- use operations from Bifoldable. -- --
--   getUnselected = getSelected . invertSelection
--   
getUnselected :: (Foldable f, Functor f) => Selection f b a -> [b] -- | Unify selected and unselected and forget the selection -- --
--   unify f g == forgetSelection . onUnselected f . onSelected g
--   
unify :: (Functor f) => (b -> c) -> (a -> c) -> Selection f b a -> f c -- | Perform a natural transformation over the underlying container of a -- selectable trans :: (Functor f) => (forall c. f c -> g c) -> Selection f b a -> Selection g b a -- | Select values based on their context within a comonad. This combinator -- makes its selection by running the predicate using extend. selectWithContext :: (Comonad w) => (w a -> Bool) -> Selection w a a -> Selection w a a instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Data.Functor.Selection.Selection f b) 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) module Control.Lens.Selection -- | Traversal over selected elements -- --
--   selected = traverse
--   
selected :: (Traversable f) => Traversal' (Selection f b a) a -- | Traversal over unselected elements -- --
--   unselected = inverting . selected
--   
unselected :: (Traversable f) => Traversal' (Selection f b a) b -- | Iso which inverts the current selection -- --
--   inverting = iso invertSelection invertSelection
--   
inverting :: (Functor f) => Iso' (Selection f b a) (Selection f a b) -- | Iso which exposes the underlying functor representation -- --
--   unwrapping = iso unwrapSelection wrapSelection
--   
unwrapping :: (Functor f) => Iso' (Selection f b a) (f (Either b a))