-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A general abstraction for manipulating elements of container data structures
--
-- An API for construction of free-form strategies of access and
-- manipulation of elements of arbitrary data structures. It allows to
-- implement efficient composite patterns, e.g., a simultaneous update
-- and lookup of an element, and even more complex things.
--
-- Strategies are meant to be interpreted by the host data structure
-- libraries. Thus they allow to implement all access and modification
-- patterns of a data structure with just a single function, which
-- interprets strategies.
--
-- This library provides pure and monadic interfaces, so it supports both
-- immutable and mutable data structures.
@package focus
@version 0.1.5
module Focus
-- | A general modification function for some match. By processing a
-- Maybe value it produces some value to emit and a
-- Decision to perform on the match.
--
-- The interpretation of this function is up to the context APIs.
type Strategy a r = Maybe a -> (r, Decision a)
-- | A monadic version of Strategy.
type StrategyM m a r = Maybe a -> m (r, Decision a)
-- | What to do with the focused value.
--
-- The interpretation of the commands is up to the context APIs.
data Decision a
Keep :: Decision a
Remove :: Decision a
Replace :: a -> Decision a
-- | Reproduces the behaviour of Data.Map.adjust.
adjust :: (a -> a) -> Strategy a ()
-- | Reproduces the behaviour of Data.Map.update.
update :: (a -> Maybe a) -> Strategy a ()
-- | Reproduces the behaviour of Data.Map.alter.
alter :: (Maybe a -> Maybe a) -> Strategy a ()
-- | Reproduces the behaviour of Data.Map.insert.
insert :: a -> Strategy a ()
-- | Reproduces the behaviour of Data.Map.delete.
delete :: Strategy a ()
-- | Reproduces the behaviour of Data.Map.lookup.
lookup :: Strategy a (Maybe a)
-- | A monadic version of adjust.
adjustM :: (Monad m) => (a -> m a) -> StrategyM m a ()
-- | A monadic version of update.
updateM :: (Monad m) => (a -> m (Maybe a)) -> StrategyM m a ()
-- | A monadic version of alter.
alterM :: (Monad m) => (Maybe a -> m (Maybe a)) -> StrategyM m a ()
-- | A monadic version of insert.
insertM :: (Monad m) => a -> StrategyM m a ()
-- | A monadic version of delete.
deleteM :: (Monad m) => StrategyM m a ()
-- | A monadic version of lookup.
lookupM :: (Monad m) => StrategyM m a (Maybe a)
instance GHC.Base.Functor Focus.Decision