-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Monadic Getters and Folds
--   
--   This package contains combinators and types for working with monadic
--   getters and folds as split off from the original lens package.
@package lens-action
@version 0.2.3

module Control.Lens.Action.Internal

-- | An Effective Functor ignores its argument and is
--   isomorphic to a Monad wrapped around a value.
--   
--   That said, the Monad is possibly rather unrelated to any
--   Applicative structure.
class (Monad m, Functor f, Contravariant f) => Effective m r f | f -> m r
effective :: Effective m r f => m r -> f a
ineffective :: Effective m r f => f a -> m r

-- | Wrap a monadic effect with a phantom type argument.
newtype Effect m r a
Effect :: m r -> Effect m r a
[getEffect] :: Effect m r a -> m r
instance GHC.Base.Functor (Control.Lens.Action.Internal.Effect m r)
instance Data.Functor.Contravariant.Contravariant (Control.Lens.Action.Internal.Effect m r)
instance GHC.Base.Monad m => Control.Lens.Action.Internal.Effective m r (Control.Lens.Action.Internal.Effect m r)
instance (Data.Functor.Bind.Class.Apply m, GHC.Base.Semigroup r) => GHC.Base.Semigroup (Control.Lens.Action.Internal.Effect m r a)
instance (Data.Functor.Bind.Class.Apply m, GHC.Base.Monad m, GHC.Base.Monoid r) => GHC.Base.Monoid (Control.Lens.Action.Internal.Effect m r a)
instance (Data.Functor.Bind.Class.Apply m, GHC.Base.Semigroup r) => Data.Functor.Bind.Class.Apply (Control.Lens.Action.Internal.Effect m r)
instance (GHC.Base.Monad m, GHC.Base.Monoid r) => GHC.Base.Applicative (Control.Lens.Action.Internal.Effect m r)
instance Control.Lens.Action.Internal.Effective m r f => Control.Lens.Action.Internal.Effective m (Data.Semigroup.Internal.Dual r) (Control.Applicative.Backwards.Backwards f)
instance Control.Lens.Action.Internal.Effective Data.Functor.Identity.Identity r (Data.Functor.Const.Const r)
instance Control.Lens.Action.Internal.Effective m r f => Control.Lens.Action.Internal.Effective m r (Control.Lens.Internal.Getter.AlongsideLeft f b)
instance Control.Lens.Action.Internal.Effective m r f => Control.Lens.Action.Internal.Effective m r (Control.Lens.Internal.Getter.AlongsideRight f b)

module Control.Lens.Action.Type

-- | An Action is a Getter enriched with access to a
--   Monad for side-effects.
--   
--   Every Getter can be used as an Action.
--   
--   You can compose an Action with another Action using
--   (.) from the Prelude.
type Action m s a = forall f r. Effective m r f => (a -> f a) -> s -> f s

-- | A MonadicFold is a Fold enriched with access to a
--   Monad for side-effects.
--   
--   A MonadicFold can use side-effects to produce parts of the
--   structure being folded (e.g. reading them from file).
--   
--   Every Fold can be used as a MonadicFold, that simply
--   ignores the access to the Monad.
--   
--   You can compose a MonadicFold with another MonadicFold
--   using (.) from the Prelude.
type MonadicFold m s a = forall f r. (Effective m r f, Applicative f) => (a -> f a) -> s -> f s
type RelevantMonadicFold m s a = forall f r. (Effective m r f, Apply f) => (a -> f a) -> s -> f s

-- | An IndexedAction is an IndexedGetter enriched with
--   access to a Monad for side-effects.
--   
--   Every Getter can be used as an Action.
--   
--   You can compose an Action with another Action using
--   (.) from the Prelude.
type IndexedAction i m s a = forall p f r. (Indexable i p, Effective m r f) => p a (f a) -> s -> f s

-- | An IndexedMonadicFold is an IndexedFold enriched with
--   access to a Monad for side-effects.
--   
--   Every IndexedFold can be used as an
--   IndexedMonadicFold, that simply ignores the access to the
--   Monad.
--   
--   You can compose an IndexedMonadicFold with another
--   IndexedMonadicFold using (.) from the Prelude.
type IndexedMonadicFold i m s a = forall p f r. (Indexable i p, Effective m r f, Applicative f) => p a (f a) -> s -> f s
type IndexedRelevantMonadicFold i m s a = forall p f r. (Indexable i p, Effective m r f, Apply f) => p a (f a) -> s -> f s

-- | An IndexPreservingAction can be used as a Action, but
--   when composed with an IndexedTraversal, IndexedFold,
--   or IndexedLens yields an IndexedMonadicFold,
--   IndexedMonadicFold or IndexedAction respectively.
type IndexPreservingAction m s a = forall p f r. (Conjoined p, Effective m r f) => p a (f a) -> p s (f s)

-- | An IndexPreservingFold can be used as a Fold, but
--   when composed with an IndexedTraversal, IndexedFold,
--   or IndexedLens yields an IndexedFold respectively.
type IndexPreservingMonadicFold m s a = forall p f r. (Conjoined p, Effective m r f, Applicative f) => p a (f a) -> p s (f s)
type IndexPreservingRelevantMonadicFold m s a = forall p f r. (Conjoined p, Effective m r f, Apply f) => p a (f a) -> p s (f s)

module Control.Lens.Action

-- | An Action is a Getter enriched with access to a
--   Monad for side-effects.
--   
--   Every Getter can be used as an Action.
--   
--   You can compose an Action with another Action using
--   (.) from the Prelude.
type Action m s a = forall f r. Effective m r f => (a -> f a) -> s -> f s

-- | Construct an Action from a monadic side-effect.
--   
--   
--   >>> ["hello","world"]^!folded.act (\x -> [x,x ++ "!"])
--   ["helloworld","helloworld!","hello!world","hello!world!"]
--   
--   
--   
--   act :: Monad m => (s -> m a) -> Action m s a
--   act sma afb a = effective (sma a >>= ineffective . afb)
--   
act :: Monad m => (s -> m a) -> IndexPreservingAction m s a

-- | A self-running Action, analogous to join.
--   
--   
--   acts ≡ act id
--   
--   
--   
--   >>> (1,"hello")^!_2.acts.to succ
--   "ifmmp"
--   
--   
--   
--   > (1,getLine)^!!_2.acts.folded.to succ
--   aa
--   "bb"
--   
acts :: IndexPreservingAction m (m a) a

-- | Perform an Action.
--   
--   
--   perform ≡ flip (^!)
--   
perform :: Monad m => Acting m a s a -> s -> m a

-- | Perform an Action and modify the result.
--   
--   
--   performs :: Monad m => Acting m e s a -> (a -> e) -> s -> m e
--   
performs :: (Profunctor p, Monad m) => Over p (Effect m e) s t a b -> p a e -> s -> m e

-- | Apply a Monad transformer to an Action.
liftAct :: (MonadTrans trans, Monad m) => Acting m a s a -> IndexPreservingAction (trans m) s a

-- | Perform an Action.
--   
--   
--   >>> ["hello","world"]^!folded.act putStrLn
--   hello
--   world
--   
(^!) :: Monad m => s -> Acting m a s a -> m a
infixr 8 ^!

-- | Perform a MonadicFold and collect all of the results in a list.
--   
--   
--   >>> ["ab","cd","ef"]^!!folded.acts
--   ["ace","acf","ade","adf","bce","bcf","bde","bdf"]
--   
--   
--   
--   > [1,2]^!!folded.act (i -> putStr (show i ++ ": ") >> getLine).each.to succ
--   1: aa
--   2: bb
--   "bbcc"
--   
(^!!) :: Monad m => s -> Acting m [a] s a -> m [a]
infixr 8 ^!!

-- | Perform a MonadicFold and collect the leftmost result.
--   
--   Note: this still causes all effects for all elements.
--   
--   
--   >>> [Just 1, Just 2, Just 3]^!?folded.acts
--   Just (Just 1)
--   
--   >>> [Just 1, Nothing]^!?folded.acts
--   Nothing
--   
(^!?) :: Monad m => s -> Acting m (Leftmost a) s a -> m (Maybe a)
infixr 8 ^!?

-- | An IndexedAction is an IndexedGetter enriched with
--   access to a Monad for side-effects.
--   
--   Every Getter can be used as an Action.
--   
--   You can compose an Action with another Action using
--   (.) from the Prelude.
type IndexedAction i m s a = forall p f r. (Indexable i p, Effective m r f) => p a (f a) -> s -> f s

-- | Construct an IndexedAction from a monadic side-effect.
iact :: Monad m => (s -> m (i, a)) -> IndexedAction i m s a

-- | Perform an IndexedAction.
--   
--   
--   iperform ≡ flip (^@!)
--   
iperform :: Monad m => IndexedActing i m (i, a) s a -> s -> m (i, a)

-- | Perform an IndexedAction and modify the result.
iperforms :: Monad m => IndexedActing i m e s a -> (i -> a -> e) -> s -> m e

-- | Perform an IndexedAction.
(^@!) :: Monad m => s -> IndexedActing i m (i, a) s a -> m (i, a)
infixr 8 ^@!

-- | Obtain a list of all of the results of an IndexedMonadicFold.
(^@!!) :: Monad m => s -> IndexedActing i m [(i, a)] s a -> m [(i, a)]
infixr 8 ^@!!

-- | Perform an IndexedMonadicFold and collect the Leftmost
--   result.
--   
--   Note: this still causes all effects for all elements.
(^@!?) :: Monad m => s -> IndexedActing i m (Leftmost (i, a)) s a -> m (Maybe (i, a))
infixr 8 ^@!?

-- | A MonadicFold is a Fold enriched with access to a
--   Monad for side-effects.
--   
--   A MonadicFold can use side-effects to produce parts of the
--   structure being folded (e.g. reading them from file).
--   
--   Every Fold can be used as a MonadicFold, that simply
--   ignores the access to the Monad.
--   
--   You can compose a MonadicFold with another MonadicFold
--   using (.) from the Prelude.
type MonadicFold m s a = forall f r. (Effective m r f, Applicative f) => (a -> f a) -> s -> f s

-- | An IndexedMonadicFold is an IndexedFold enriched with
--   access to a Monad for side-effects.
--   
--   Every IndexedFold can be used as an
--   IndexedMonadicFold, that simply ignores the access to the
--   Monad.
--   
--   You can compose an IndexedMonadicFold with another
--   IndexedMonadicFold using (.) from the Prelude.
type IndexedMonadicFold i m s a = forall p f r. (Indexable i p, Effective m r f, Applicative f) => p a (f a) -> s -> f s

-- | Used to evaluate an Action.
type Acting m r s a = LensLike (Effect m r) s s a a

-- | Used to evaluate an IndexedAction.
type IndexedActing i m r s a = Over (Indexed i) (Effect m r) s s a a

-- | An Effective Functor ignores its argument and is
--   isomorphic to a Monad wrapped around a value.
--   
--   That said, the Monad is possibly rather unrelated to any
--   Applicative structure.
class (Monad m, Functor f, Contravariant f) => Effective m r f | f -> m r

module Control.Lens.Action.Reified

-- | Reify a ReifiedMonadicFold so it can be stored safely in a
--   container.
newtype ReifiedMonadicFold m s a
MonadicFold :: MonadicFold m s a -> ReifiedMonadicFold m s a
[runMonadicFold] :: ReifiedMonadicFold m s a -> MonadicFold m s a
instance Data.Profunctor.Unsafe.Profunctor (Control.Lens.Action.Reified.ReifiedMonadicFold m)
instance Data.Profunctor.Strong.Strong (Control.Lens.Action.Reified.ReifiedMonadicFold m)
instance Data.Profunctor.Choice.Choice (Control.Lens.Action.Reified.ReifiedMonadicFold m)
instance Control.Category.Category (Control.Lens.Action.Reified.ReifiedMonadicFold m)
instance Control.Arrow.Arrow (Control.Lens.Action.Reified.ReifiedMonadicFold m)
instance Control.Arrow.ArrowChoice (Control.Lens.Action.Reified.ReifiedMonadicFold m)
instance Control.Arrow.ArrowApply (Control.Lens.Action.Reified.ReifiedMonadicFold m)
instance GHC.Base.Functor (Control.Lens.Action.Reified.ReifiedMonadicFold m s)
instance Data.Functor.Bind.Class.Apply (Control.Lens.Action.Reified.ReifiedMonadicFold m s)
instance GHC.Base.Applicative (Control.Lens.Action.Reified.ReifiedMonadicFold m s)
instance GHC.Base.Alternative (Control.Lens.Action.Reified.ReifiedMonadicFold m s)
instance Data.Functor.Bind.Class.Bind (Control.Lens.Action.Reified.ReifiedMonadicFold m s)
instance GHC.Base.Monad (Control.Lens.Action.Reified.ReifiedMonadicFold m s)
instance Control.Monad.Reader.Class.MonadReader s (Control.Lens.Action.Reified.ReifiedMonadicFold m s)
instance GHC.Base.MonadPlus (Control.Lens.Action.Reified.ReifiedMonadicFold m s)
instance GHC.Base.Semigroup (Control.Lens.Action.Reified.ReifiedMonadicFold m s a)
instance GHC.Base.Monoid (Control.Lens.Action.Reified.ReifiedMonadicFold m s a)
instance Data.Functor.Alt.Alt (Control.Lens.Action.Reified.ReifiedMonadicFold m s)
instance Data.Functor.Plus.Plus (Control.Lens.Action.Reified.ReifiedMonadicFold m s)
