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


-- | Implementation of the Freer Monad
--   
--   Freer is an implementation of "Freer Monads, More Extensible Effects"
--   
--   The key features of Freer are:
--   
--   <ul>
--   <li>An efficient effect system for Haskell - as a library!</li>
--   <li>Implementations for several common Haskell monad instances:</li>
--   <li>Core components for defining your own Effects</li>
--   </ul>
@package freer
@version 0.2.4.1


-- | <ul>
--   <li>Constant-time append<i>(&gt;&lt;) and snoc</i>(|&gt;)</li>
--   <li>Average constant-time viewL (left-edge deconstruction)</li>
--   </ul>
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/FTCQueue1.hs</a> as a
--   starting point.
--   
--   A minimal version of FTCQueue from "Reflection w/o Remorse":
--   
--   <ul>
--   <li>research: <a>http://okmij.org/ftp/Haskell/Reflection.html</a></li>
--   <li>type-aligned(FTCQueue):
--   <a>https://hackage.haskell.org/package/type-aligned</a></li>
--   </ul>
module Data.FTCQueue

-- | Non-empty tree. Deconstruction operations make it more and more
--   left-leaning
data FTCQueue m a b

-- | Build a leaf from a single operation [O(1)]
tsingleton :: (a -> m b) -> FTCQueue m a b

-- | Append an operation to the right of the tree [O(1)]
(|>) :: FTCQueue m a x -> (x -> m b) -> FTCQueue m a b

-- | An alias for '(|&gt;)'
snoc :: FTCQueue m a x -> (x -> m b) -> FTCQueue m a b

-- | Append two trees of operations [O(1)]
(><) :: FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b

-- | An alias for '(&gt;&lt;)'
append :: FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b

-- | Left view deconstruction data structure
data ViewL m a b
[TOne] :: (a -> m b) -> ViewL m a b
[:|] :: (a -> m x) -> FTCQueue m x b -> ViewL m a b

-- | Left view deconstruction [average O(1)]
tviewl :: FTCQueue m a b -> ViewL m a b

module Data.Open.Union.Internal
data Union (r :: [* -> *]) v
[UNow] :: t v -> Union (t : r) v
[UNext] :: Union (t : r) v -> Union (any : (t : r)) v
data Nat
S :: Nat -> Nat
Z :: Nat
data P (n :: Nat)
P :: P
class Member' t r (n :: Nat)
inj' :: Member' t r n => P n -> t v -> Union r v
prj' :: Member' t r n => P n -> Union r v -> Maybe (t v)
decomp :: Union (t : r) v -> Either (Union r v) (t v)
weaken :: Union (t : r) w -> Union (any : (t : r)) w
extract :: Union '[t] v -> t v
class (Member' t r (FindElem t r)) => Member t r
inj :: Member t r => t v -> Union r v
prj :: Member t r => Union r v -> Maybe (t v)
instance Data.Open.Union.Internal.Member' t r (Data.Open.Union.Internal.FindElem t r) => Data.Open.Union.Internal.Member t r
instance GHC.Base.Functor f => GHC.Base.Functor (Data.Open.Union.Internal.Union '[f])
instance (GHC.Base.Functor f1, GHC.Base.Functor (Data.Open.Union.Internal.Union (f2 : fs))) => GHC.Base.Functor (Data.Open.Union.Internal.Union (f1 : f2 : fs))
instance r ~ (t : r') => Data.Open.Union.Internal.Member' t r 'Data.Open.Union.Internal.Z
instance (r ~ (t' : r' : rs'), Data.Open.Union.Internal.Member' t (r' : rs') n) => Data.Open.Union.Internal.Member' t r ('Data.Open.Union.Internal.S n)


-- | This implementation relies on _closed_ type families added to GHC 7.8.
--   It has NO overlapping instances and NO Typeable. Alas, the absence of
--   Typeable means the projections and injections generally take linear
--   time. The code illustrate how to use closed type families to
--   disambiguate otherwise overlapping instances.
--   
--   The data constructors of Union are not exported. Essentially, the
--   nested Either data type.
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/OpenUnion41.hs</a> as
--   a starting point.
module Data.Open.Union
data Union (r :: [* -> *]) v
class (Member' t r (FindElem t r)) => Member t r
inj :: Member t r => t v -> Union r v
prj :: Member t r => Union r v -> Maybe (t v)
decomp :: Union (t : r) v -> Either (Union r v) (t v)
weaken :: Union (t : r) w -> Union (any : (t : r)) w
extract :: Union '[t] v -> t v

-- | The <a>Functor</a> class is used for types that can be mapped over.
--   Instances of <a>Functor</a> should satisfy the following laws:
--   
--   <pre>
--   fmap id  ==  id
--   fmap (f . g)  ==  fmap f . fmap g
--   </pre>
--   
--   The instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
--   satisfy these laws.
class Functor (f :: * -> *)
fmap :: Functor f => (a -> b) -> f a -> f b

-- | Replace all locations in the input with the same value. The default
--   definition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
--   overridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a


-- | Internal machinery for this effects library. This includes:
--   
--   <ul>
--   <li>Eff data type, for expressing effects</li>
--   <li>NonDetEff data type, for nondeterministic effects</li>
--   <li>Functions for facilitating the construction of effects and their
--   handlers</li>
--   </ul>
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/Eff1.hs</a> as a
--   starting point.
module Control.Monad.Freer.Internal

-- | The Eff representation.
--   
--   Status of a coroutine (client): * Val: Done with the value of type a *
--   E : Sending a request of type Union r with the continuation Arrs r b a
data Eff r a
Val :: a -> Eff r a
E :: (Union r b) -> (Arrs r b a) -> Eff r a
class (Member' t r (FindElem t r)) => Member t r
inj :: Member t r => t v -> Union r v
prj :: Member t r => Union r v -> Maybe (t v)

-- | Effectful arrow type: a function from a to b that also does effects
--   denoted by r
type Arr r a b = a -> Eff r b

-- | An effectful function from <tt>a</tt> to <tt>b</tt> that is a
--   composition of several effectful functions. The paremeter r describes
--   the overall effect. The composition members are accumulated in a
--   type-aligned queue.
type Arrs r a b = FTCQueue (Eff r) a b
data Union (r :: [* -> *]) v

-- | A data type for representing nondeterminstic choice
data NonDetEff a
[MZero] :: NonDetEff a
[MPlus] :: NonDetEff Bool

-- | A handler for nondeterminstic effects
makeChoiceA :: Alternative f => Eff (NonDetEff : r) a -> Eff r (f a)
msplit :: Member NonDetEff r => Eff r a -> Eff r (Maybe (a, Eff r a))
decomp :: Union (t : r) v -> Either (Union r v) (t v)

-- | Build a leaf from a single operation [O(1)]
tsingleton :: (a -> m b) -> FTCQueue m a b
extract :: Union '[t] v -> t v

-- | Function application in the context of an array of effects, Arrs r b w
qApp :: Arrs r b w -> b -> Eff r w

-- | Composition of effectful arrows Allows for the caller to change the
--   effect environment, as well
qComp :: Arrs r a b -> (Eff r b -> Eff r' c) -> Arr r' a c

-- | send a request and wait for a reply
send :: Member t r => t v -> Eff r v

-- | Runs a set of Effects. Requires that all effects are consumed.
--   Typically composed as follows: &gt; run . runEff1 eff1Arg . runEff2
--   eff2Arg1 eff2Arg2 (program)
run :: Eff '[] w -> w

-- | Runs a set of Effects. Requires that all effects are consumed, except
--   for a single effect known to be a monad. The value returned is a
--   computation in that monad. This is useful for plugging in traditional
--   transformer stacks.
runM :: Monad m => Eff '[m] w -> m w

-- | Given a request, either handle it or relay it.
handleRelay :: (a -> Eff r w) -> (forall v. t v -> Arr r v w -> Eff r w) -> Eff (t : r) a -> Eff r w

-- | Parameterized <a>handleRelay</a> Allows sending along some state to be
--   handled for the target effect, or relayed to a handler that can handle
--   the target effect.
handleRelayS :: s -> (s -> a -> Eff r w) -> (forall v. s -> t v -> (s -> Arr r v w) -> Eff r w) -> Eff (t : r) a -> Eff r w

-- | Intercept the request and possibly reply to it, but leave it unhandled
interpose :: Member t r => (a -> Eff r w) -> (forall v. t v -> Arr r v w -> Eff r w) -> Eff r a -> Eff r w
instance Data.Open.Union.Internal.Member Control.Monad.Freer.Internal.NonDetEff r => GHC.Base.Alternative (Control.Monad.Freer.Internal.Eff r)
instance Data.Open.Union.Internal.Member Control.Monad.Freer.Internal.NonDetEff r => GHC.Base.MonadPlus (Control.Monad.Freer.Internal.Eff r)
instance GHC.Base.Functor (Control.Monad.Freer.Internal.Eff r)
instance GHC.Base.Applicative (Control.Monad.Freer.Internal.Eff r)
instance GHC.Base.Monad (Control.Monad.Freer.Internal.Eff r)


-- | Writer effects, for writing changes to an attached environment.
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/Eff1.hs</a> as a
--   starting point.
module Control.Monad.Freer.Writer

-- | Writer effects - send outputs to an effect environment
data Writer o x
[Writer] :: o -> Writer o ()

-- | Send a change to the attached environment
tell :: Member (Writer o) r => o -> Eff r ()

-- | Simple handler for Writer effects
runWriter :: Monoid o => Eff (Writer o : r) a -> Eff r (a, o)


-- | Composable handler for Trace effects. Trace allows one to debug the
--   operation of sequences of effects by outputing to the console.
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/Eff1.hs</a> as a
--   starting point.
module Control.Monad.Freer.Trace

-- | A Trace effect; takes a String and performs output
data Trace v

-- | Printing a string in a trace
trace :: Member Trace r => String -> Eff r ()

-- | An IO handler for Trace effects
runTrace :: Eff '[Trace] w -> IO w


-- | Composable handler for State effects.
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/Eff1.hs</a> as a
--   starting point.
module Control.Monad.Freer.State

-- | Strict State effects: one can either Get values or Put them
data State s v

-- | Retrieve state
get :: Member (State s) r => Eff r s

-- | Store state
put :: Member (State s) r => s -> Eff r ()

-- | Modify state
modify :: Member (State s) r => (s -> s) -> Eff r ()

-- | Handler for State effects
runState :: Eff (State s : r) w -> s -> Eff r (w, s)

-- | An encapsulated State handler, for transactional semantics The global
--   state is updated only if the transactionState finished successfully
transactionState :: forall s r w. Member (State s) r => Proxy s -> Eff r w -> Eff r w


-- | Composable handler for Reader effects. Handy for encapsulating an
--   environment with immutable state for interpreters.
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/Eff1.hs</a> as a
--   starting point.
module Control.Monad.Freer.Reader
data Reader e v
[Reader] :: Reader e e

-- | Request a value for the environment
ask :: (Member (Reader e) r) => Eff r e

-- | Request a value from the environment and applys as function
asks :: (b -> a) -> Eff '[Reader b] a

-- | Handler for reader effects
runReader :: Eff (Reader e : r) w -> e -> Eff r w

-- | Locally rebind the value in the dynamic environment This function is
--   like a relay; it is both an admin for Reader requests, and a requestor
--   of them
local :: forall e a r. Member (Reader e) r => (e -> e) -> Eff r a -> Eff r a


-- | Composable handler for State effects in terms of Reader/Writer
--   effects. This module is more a tutorial on how to compose handlers. It
--   is slightly slower than a dedicated State handler.
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/Eff1.hs</a> as a
--   starting point.
module Control.Monad.Freer.StateRW

-- | State handler, using Reader/Writer effects
runStateR :: Eff (Writer s : (Reader s : r)) w -> s -> Eff r (w, s)
data Reader e v

-- | Writer effects - send outputs to an effect environment
data Writer o x

-- | Send a change to the attached environment
tell :: Member (Writer o) r => o -> Eff r ()

-- | Request a value for the environment
ask :: (Member (Reader e) r) => Eff r e


-- | Composable handler for Fresh effects. This is likely to be of use when
--   implementing De Bruijn naming/scopes.
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/Eff1.hs</a> as a
--   starting point.
module Control.Monad.Freer.Fresh

-- | Fresh effect model
data Fresh v

-- | Request a fresh effect
fresh :: Member Fresh r => Eff r Int

-- | Handler for Fresh effects, with an Int for a starting value
runFresh' :: Eff (Fresh : r) w -> Int -> Eff r w


-- | Composable handler for Exception effects. Communicates success/failure
--   via an Either type.
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/Eff1.hs</a> as a
--   starting point.
module Control.Monad.Freer.Exception

-- | Exceptions of the type e; no resumption
newtype Exc e v
Exc :: e -> Exc e v

-- | Throws an error carrying information of type e
throwError :: (Member (Exc e) r) => e -> Eff r a

-- | Handler for exception effects If there are no exceptions thrown,
--   returns Right If exceptions are thrown and not handled, returns Left,
--   interrupting the execution of any other effect handlers.
runError :: Eff (Exc e : r) a -> Eff r (Either e a)

-- | A catcher for Exceptions. Handlers are allowed to rethrow exceptions.
catchError :: Member (Exc e) r => Eff r a -> (e -> Eff r a) -> Eff r a


-- | Composable handler for logical Cut effects. Implemented in terms of
--   Exc effect.
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/Eff1.hs</a> as a
--   starting point.
module Control.Monad.Freer.Cut
data CutFalse

-- | Implementation of logical Cut using Exc effects.
cutFalse :: Member (Exc CutFalse) r => Eff r a


-- | An effect to compose functions with the ability to yield.
--   
--   Using <a>http://okmij.org/ftp/Haskell/extensible/Eff1.hs</a> as a
--   starting point.
module Control.Monad.Freer.Coroutine

-- | A type representing a yielding of control a: The current type b: The
--   input to the continuation function v: The output of the continuation
data Yield a b v

-- | Lifts a value and a function into the Coroutine effect
yield :: (Member (Yield a b) r) => a -> (b -> c) -> Eff r c

-- | Status of a thread: done or reporting the value of the type a and
--   resuming with the value of type b
data Status r a b
Done :: Status r a b
Continue :: a -> (b -> Eff r (Status r a b)) -> Status r a b

-- | Launch a thread and report its status
runC :: Eff (Yield a b : r) w -> Eff r (Status r a b)
instance GHC.Base.Functor (Control.Monad.Freer.Coroutine.Yield a b)


module Control.Monad.Freer
class (Member' t r (FindElem t r)) => Member t r

-- | The Eff representation.
--   
--   Status of a coroutine (client): * Val: Done with the value of type a *
--   E : Sending a request of type Union r with the continuation Arrs r b a
data Eff r a

-- | Runs a set of Effects. Requires that all effects are consumed.
--   Typically composed as follows: &gt; run . runEff1 eff1Arg . runEff2
--   eff2Arg1 eff2Arg2 (program)
run :: Eff '[] w -> w

-- | Runs a set of Effects. Requires that all effects are consumed, except
--   for a single effect known to be a monad. The value returned is a
--   computation in that monad. This is useful for plugging in traditional
--   transformer stacks.
runM :: Monad m => Eff '[m] w -> m w
runNat :: forall m r e w. (Member m r) => (forall a. e a -> m a) -> Eff (e : r) w -> Eff r w

-- | Given a request, either handle it or relay it.
handleRelay :: (a -> Eff r w) -> (forall v. t v -> Arr r v w -> Eff r w) -> Eff (t : r) a -> Eff r w

-- | Parameterized <a>handleRelay</a> Allows sending along some state to be
--   handled for the target effect, or relayed to a handler that can handle
--   the target effect.
handleRelayS :: s -> (s -> a -> Eff r w) -> (forall v. s -> t v -> (s -> Arr r v w) -> Eff r w) -> Eff (t : r) a -> Eff r w

-- | send a request and wait for a reply
send :: Member t r => t v -> Eff r v

-- | Effectful arrow type: a function from a to b that also does effects
--   denoted by r
type Arr r a b = a -> Eff r b

-- | A data type for representing nondeterminstic choice
data NonDetEff a
[MZero] :: NonDetEff a
[MPlus] :: NonDetEff Bool

-- | A handler for nondeterminstic effects
makeChoiceA :: Alternative f => Eff (NonDetEff : r) a -> Eff r (f a)
msplit :: Member NonDetEff r => Eff r a -> Eff r (Maybe (a, Eff r a))
