-- 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.2

module Focus

-- | A general modification function for some match. By processing a
--   <a>Maybe</a> value it produces some value to emit and a
--   <a>Decision</a> 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 <a>Strategy</a>.
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 <tt>Data.Map.<a>adjust</a></tt>.
adjust :: (a -> a) -> Strategy a ()

-- | Reproduces the behaviour of <tt>Data.Map.<a>update</a></tt>.
update :: (a -> Maybe a) -> Strategy a ()

-- | Reproduces the behaviour of <tt>Data.Map.<a>alter</a></tt>.
alter :: (Maybe a -> Maybe a) -> Strategy a ()

-- | Reproduces the behaviour of <tt>Data.Map.<a>insert</a></tt>.
insert :: a -> Strategy a ()

-- | Reproduces the behaviour of <tt>Data.Map.<a>delete</a></tt>.
delete :: Strategy a ()

-- | Reproduces the behaviour of <tt>Data.Map.<a>lookup</a></tt>.
lookup :: Strategy a (Maybe a)

-- | A monadic version of <a>adjust</a>.
adjustM :: (Monad m) => (a -> m a) -> StrategyM m a ()

-- | A monadic version of <a>update</a>.
updateM :: (Monad m) => (a -> m (Maybe a)) -> StrategyM m a ()

-- | A monadic version of <a>alter</a>.
alterM :: (Monad m) => (Maybe a -> m (Maybe a)) -> StrategyM m a ()

-- | A monadic version of <a>insert</a>.
insertM :: (Monad m) => a -> StrategyM m a ()

-- | A monadic version of <a>delete</a>.
deleteM :: (Monad m) => StrategyM m a ()

-- | A monadic version of <a>lookup</a>.
lookupM :: (Monad m) => StrategyM m a (Maybe a)
instance GHC.Base.Functor Focus.Decision
