-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Arrow classes and transformers -- -- Several classes that extend the Arrow class, and some transformers -- that implement or lift these classes. @package arrows @version 0.4.4.2 -- | Subclasses of Arrow providing additional operations. -- -- The signatures are designed to be compatible with the proposed -- notation for arrows, cf. http://www.haskell.org/arrows/. module Control.Arrow.Operations -- | An arrow type that provides a modifiable state, based of section 9 of -- Generalising Monads to Arrows, by John Hughes, Science of -- Computer Programming 37:67-111, May 2000. class Arrow a => ArrowState s a | a -> s -- | Obtain the current value of the state. fetch :: ArrowState s a => a e s -- | Assign a new value to the state. store :: ArrowState s a => a s () -- | An arrow type that provides a read-only state (an environment). If you -- also need to modify the state, use ArrowState. class Arrow a => ArrowReader r a | a -> r -- | Obtain the current value of the state. readState :: ArrowReader r a => a b r -- | Run a subcomputation in the same arrow, but with a different -- environment. The environment of the outer computation is unaffected. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- (|newReader cmd|) env --newReader :: ArrowReader r a => a e b -> a (e, r) b -- | An arrow type that collects additional output (of some Monoid -- type). class (Monoid w, Arrow a) => ArrowWriter w a | a -> w -- | Add a piece of additional output. write :: ArrowWriter w a => a w () -- | Run a subcomputation in the same arrow, making its additional output -- accessible. -- -- Typical usage in arrow notation: -- --
-- proc p -> do -- ... -- (value, output) <- (|newWriter cmd|) --newWriter :: ArrowWriter w a => a e b -> a e (b, w) -- | An arrow type that includes errors (or exceptions). -- -- Minimal definition: raise and tryInUnless. -- -- TODO: the operations here are inconsistent with other arrow -- transformers. class Arrow a => ArrowError ex a | a -> ex -- | Raise an error. raise :: ArrowError ex a => a ex b -- | Traditional exception construct. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- body `handle` \ex -> handler --handle :: ArrowError ex a => a e b -> a (e, ex) b -> a e b -- | Exception construct in the style of Exceptional Syntax, by Nick -- Benton and Andrew Kennedy, JFP 11(4):395-410, July 2001. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- (|tryInUnless -- body -- (\res -> success) -- (\ex -> handler) -- |) --tryInUnless :: ArrowError ex a => a e b -> a (e, b) c -> a (e, ex) c -> a e c -- | Handler that returns the error as a value. newError :: ArrowError ex a => a e b -> a e (Either ex b) -- | A suitable value for tryInUnless when the arrow type belongs to -- ArrowChoice. To use it, you must define either handle or -- newError. tryInUnlessDefault :: (ArrowError ex a, ArrowChoice a) => a e b -> a (e, b) c -> a (e, ex) c -> a e c -- | An arrow type that can be used to interpret synchronous circuits. class ArrowLoop a => ArrowCircuit a -- | A delay component. delay :: ArrowCircuit a => b -> a b b -- | Arrow transformers, for making new arrow types out of old ones. module Control.Arrow.Transformer -- | Construct a new arrow from an existing one. class (Arrow a, Arrow (f a)) => ArrowTransformer f a -- | A transformation of arrows, preserving arr, >>> -- and first. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- (|lift cmd|) --lift :: ArrowTransformer f a => a b c -> f a b c -- | Simple Mealy-style automata. module Control.Arrow.Transformer.Automaton -- | An arrow type comprising Mealy-style automata, each step of which is -- is a computation in the original arrow type. newtype Automaton a b c Automaton :: (a b (c, Automaton a b c)) -> Automaton a b c -- | Encapsulating an automaton by running it on a stream of inputs, -- obtaining a stream of outputs. -- -- Typical usage in arrow notation: -- --
-- proc p -> do -- ... -- ys <- (|runAutomaton (\x -> ...)|) xs ---- -- Here xs refers to the input stream and x to -- individual elements of that stream. ys is bound to the output -- stream. runAutomaton :: (ArrowLoop a, ArrowApply a) => Automaton a (e, b) c -> a (e, Stream b) (Stream c) instance Control.Arrow.Arrow a => Control.Arrow.Transformer.ArrowTransformer Control.Arrow.Transformer.Automaton.Automaton a instance Control.Arrow.Arrow a => Control.Category.Category (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.Arrow a => Control.Arrow.Arrow (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.ArrowChoice a => Control.Arrow.ArrowChoice (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.ArrowZero a => Control.Arrow.ArrowZero (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.ArrowPlus a => Control.Arrow.ArrowPlus (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.ArrowLoop a => Control.Arrow.ArrowLoop (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.ArrowLoop a => Control.Arrow.Operations.ArrowCircuit (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.Arrow a => GHC.Base.Functor (Control.Arrow.Transformer.Automaton.Automaton a b) instance Control.Arrow.Arrow a => GHC.Base.Applicative (Control.Arrow.Transformer.Automaton.Automaton a b) instance Control.Arrow.ArrowPlus a => GHC.Base.Alternative (Control.Arrow.Transformer.Automaton.Automaton a b) instance Control.Arrow.ArrowPlus a => Data.Semigroup.Semigroup (Control.Arrow.Transformer.Automaton.Automaton a b c) instance Control.Arrow.ArrowPlus a => GHC.Base.Monoid (Control.Arrow.Transformer.Automaton.Automaton a b c) instance (Control.Arrow.ArrowLoop a, Control.Arrow.ArrowApply a) => Control.Arrow.Internals.ArrowAddStream (Control.Arrow.Transformer.Automaton.Automaton a) a instance Control.Arrow.Operations.ArrowWriter w a => Control.Arrow.Operations.ArrowWriter w (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.Operations.ArrowError r a => Control.Arrow.Operations.ArrowError r (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.Operations.ArrowReader r a => Control.Arrow.Operations.ArrowReader r (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.Operations.ArrowState s a => Control.Arrow.Operations.ArrowState s (Control.Arrow.Transformer.Automaton.Automaton a) instance Control.Arrow.Internals.ArrowAddWriter w a a' => Control.Arrow.Internals.ArrowAddWriter w (Control.Arrow.Transformer.Automaton.Automaton a) (Control.Arrow.Transformer.Automaton.Automaton a') instance Control.Arrow.Internals.ArrowAddReader r a a' => Control.Arrow.Internals.ArrowAddReader r (Control.Arrow.Transformer.Automaton.Automaton a) (Control.Arrow.Transformer.Automaton.Automaton a') instance Control.Arrow.Internals.ArrowAddState r a a' => Control.Arrow.Internals.ArrowAddState r (Control.Arrow.Transformer.Automaton.Automaton a) (Control.Arrow.Transformer.Automaton.Automaton a') -- | Transformation of state readers. -- -- TODO: define operations for this arrow. module Control.Arrow.Transformer.CoState newtype CoStateArrow s a b c CoStateArrow :: (a (s -> b) (s -> c)) -> CoStateArrow s a b c instance Control.Category.Category a => Control.Category.Category (Control.Arrow.Transformer.CoState.CoStateArrow s a) instance Control.Arrow.Arrow a => Control.Arrow.Arrow (Control.Arrow.Transformer.CoState.CoStateArrow s a) instance Control.Arrow.ArrowLoop a => Control.Arrow.ArrowLoop (Control.Arrow.Transformer.CoState.CoStateArrow s a) instance Control.Arrow.ArrowZero a => Control.Arrow.ArrowZero (Control.Arrow.Transformer.CoState.CoStateArrow s a) instance Control.Arrow.ArrowPlus a => Control.Arrow.ArrowPlus (Control.Arrow.Transformer.CoState.CoStateArrow s a) instance Control.Arrow.Arrow a => GHC.Base.Functor (Control.Arrow.Transformer.CoState.CoStateArrow s a b) instance Control.Arrow.Arrow a => GHC.Base.Applicative (Control.Arrow.Transformer.CoState.CoStateArrow s a b) instance Control.Arrow.ArrowPlus a => GHC.Base.Alternative (Control.Arrow.Transformer.CoState.CoStateArrow s a b) instance Control.Arrow.ArrowPlus a => Data.Semigroup.Semigroup (Control.Arrow.Transformer.CoState.CoStateArrow s a b c) instance Control.Arrow.ArrowPlus a => GHC.Base.Monoid (Control.Arrow.Transformer.CoState.CoStateArrow s a b c) -- | An arrow transformer that adds error handling. -- -- TODO: the operations here are inconsistent with other arrow -- transformers. module Control.Arrow.Transformer.Error -- | An arrow that augments an existing arrow with possible errors. The -- ArrowError class contains methods for raising and handling -- these errors. newtype ErrorArrow ex a b c ErrorArrow :: (a b (Either ex c)) -> ErrorArrow ex a b c -- | Encapsulate an error-raising computation, by completely handling any -- errors. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- body `runError` \ex -> handler --runError :: ArrowChoice a => ErrorArrow ex a e b -> a (e, ex) b -> a e b -- | Adding a ErrorArrow to an arrow type, but not necessarily as -- the outer arrow transformer. -- -- Typically a composite arrow type is built by applying a series of -- arrow transformer to a base arrow (usually either a function arrow or -- a Kleisli arrow. One can add a transformer to the top of this -- stack using the lift method of the ArrowTransformer -- class, or remove a state transformer from the top of the stack using -- the runError encapsulation operator. The methods of this class -- add and remove state transformers anywhere in the stack. In the -- instance -- --
-- instance Arrow a => ArrowAddError ex (ArrowError ex a) a ---- -- they are equivalent to lift and runError respectively. -- Instances are lifted through other transformers with -- --
-- instance ArrowAddError ex a a' => -- ArrowAddError ex (FooArrow a) (FooArrow a') ---- -- This could be combined with handle, since the resulting arrow -- is always the arrow of the handler. Separating them has the advantage -- of consistency with the other arrows, and might give more helpful type -- error messages. class (ArrowError ex a, Arrow a') => ArrowAddError ex a a' | a -> a' -- | Lift a computation from an arrow to one with error handling. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- (|liftError cmd|) --liftError :: ArrowAddError ex a a' => a' e b -> a e b -- | Elimination of errors from a computation, by completely handling any -- errors. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- body `elimError` \ex -> handler --elimError :: ArrowAddError ex a a' => a e b -> a' (e, ex) b -> a' e b instance Control.Arrow.ArrowChoice a => Control.Arrow.Transformer.ArrowTransformer (Control.Arrow.Transformer.Error.ErrorArrow ex) a instance Control.Arrow.ArrowChoice a => Control.Category.Category (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance Control.Arrow.ArrowChoice a => Control.Arrow.Arrow (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance Control.Arrow.ArrowChoice a => Control.Arrow.ArrowChoice (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance (Control.Arrow.ArrowChoice a, Control.Arrow.ArrowApply a) => Control.Arrow.ArrowApply (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance (Control.Arrow.ArrowChoice a, Control.Arrow.ArrowLoop a) => Control.Arrow.ArrowLoop (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance Control.Arrow.ArrowChoice a => GHC.Base.Functor (Control.Arrow.Transformer.Error.ErrorArrow ex a b) instance Control.Arrow.ArrowChoice a => GHC.Base.Applicative (Control.Arrow.Transformer.Error.ErrorArrow ex a b) instance (GHC.Base.Monoid ex, Control.Arrow.ArrowChoice a) => GHC.Base.Alternative (Control.Arrow.Transformer.Error.ErrorArrow ex a b) instance (GHC.Base.Monoid ex, Control.Arrow.ArrowChoice a) => Data.Semigroup.Semigroup (Control.Arrow.Transformer.Error.ErrorArrow ex a b c) instance (GHC.Base.Monoid ex, Control.Arrow.ArrowChoice a) => GHC.Base.Monoid (Control.Arrow.Transformer.Error.ErrorArrow ex a b c) instance Control.Arrow.ArrowChoice a => Control.Arrow.Operations.ArrowError ex (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance Control.Arrow.ArrowChoice a => Control.Arrow.Internals.ArrowAddError ex (Control.Arrow.Transformer.Error.ErrorArrow ex a) a instance (GHC.Base.Monoid ex, Control.Arrow.ArrowChoice a) => Control.Arrow.ArrowZero (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance (GHC.Base.Monoid ex, Control.Arrow.ArrowChoice a) => Control.Arrow.ArrowPlus (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance (Control.Arrow.Operations.ArrowReader r a, Control.Arrow.ArrowChoice a) => Control.Arrow.Operations.ArrowReader r (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance (Control.Arrow.Operations.ArrowState s a, Control.Arrow.ArrowChoice a) => Control.Arrow.Operations.ArrowState s (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance (Control.Arrow.Operations.ArrowWriter w a, Control.Arrow.ArrowChoice a) => Control.Arrow.Operations.ArrowWriter w (Control.Arrow.Transformer.Error.ErrorArrow ex a) instance (Control.Arrow.Internals.ArrowAddReader r a a', Control.Arrow.ArrowChoice a, Control.Arrow.ArrowChoice a') => Control.Arrow.Internals.ArrowAddReader r (Control.Arrow.Transformer.Error.ErrorArrow ex a) (Control.Arrow.Transformer.Error.ErrorArrow ex a') instance (Control.Arrow.Internals.ArrowAddState s a a', Control.Arrow.ArrowChoice a, Control.Arrow.ArrowChoice a') => Control.Arrow.Internals.ArrowAddState s (Control.Arrow.Transformer.Error.ErrorArrow ex a) (Control.Arrow.Transformer.Error.ErrorArrow ex a') instance (Control.Arrow.Internals.ArrowAddWriter w a a', Control.Arrow.ArrowChoice a, Control.Arrow.ArrowChoice a') => Control.Arrow.Internals.ArrowAddWriter w (Control.Arrow.Transformer.Error.ErrorArrow ex a) (Control.Arrow.Transformer.Error.ErrorArrow ex a') -- | Arrow transformer that adds a read-only state (i.e. an environment). module Control.Arrow.Transformer.Reader -- | An arrow type that augments an existing arrow with a read-only state -- (or environment). The ArrowReader class contains the operations -- on this state. newtype ReaderArrow r a b c ReaderArrow :: (a (b, r) c) -> ReaderArrow r a b c -- | Encapsulation of a state-reading computation, taking a value for the -- state. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- (|runReader cmd|) env --runReader :: Arrow a => ReaderArrow r a e b -> a (e, r) b -- | Adding a ReaderArrow to an arrow type, but not necessarily as -- the outer arrow transformer. -- -- Typically a composite arrow type is built by applying a series of -- arrow transformer to a base arrow (usually either a function arrow or -- a Kleisli arrow. One can add a transformer to the top of this -- stack using the lift method of the ArrowTransformer -- class, or remove a state transformer from the top of the stack using -- the runReader encapsulation operator. The methods of this class -- add and remove state transformers anywhere in the stack. In the -- instance -- --
-- instance Arrow a => ArrowAddReader r (ArrowReader r a) a ---- -- they are equivalent to lift and runReader respectively. -- Instances are lifted through other transformers with -- --
-- instance ArrowAddReader r a a' => -- ArrowAddReader r (FooArrow a) (FooArrow a') --class (ArrowReader r a, Arrow a') => ArrowAddReader r a a' | a -> a' -- | Lift a computation from an arrow to one with an added environment. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- (|liftReader cmd|) --liftReader :: ArrowAddReader r a a' => a' e b -> a e b -- | Elimination of a state reader from a computation, taking a value for -- the state. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- (|elimReader cmd|) env --elimReader :: ArrowAddReader r a a' => a e b -> a' (e, r) b instance Control.Arrow.Arrow a => Control.Arrow.Transformer.ArrowTransformer (Control.Arrow.Transformer.Reader.ReaderArrow r) a instance Control.Arrow.Arrow a => Control.Category.Category (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.Arrow a => Control.Arrow.Arrow (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.ArrowChoice a => Control.Arrow.ArrowChoice (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.ArrowApply a => Control.Arrow.ArrowApply (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.ArrowZero a => Control.Arrow.ArrowZero (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.ArrowPlus a => Control.Arrow.ArrowPlus (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.ArrowLoop a => Control.Arrow.ArrowLoop (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.Arrow a => Control.Arrow.Operations.ArrowReader r (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.Arrow a => Control.Arrow.Internals.ArrowAddReader r (Control.Arrow.Transformer.Reader.ReaderArrow r a) a instance Control.Arrow.Operations.ArrowCircuit a => Control.Arrow.Operations.ArrowCircuit (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.Operations.ArrowError ex a => Control.Arrow.Operations.ArrowError ex (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.Operations.ArrowState s a => Control.Arrow.Operations.ArrowState s (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.Operations.ArrowWriter s a => Control.Arrow.Operations.ArrowWriter s (Control.Arrow.Transformer.Reader.ReaderArrow r a) instance Control.Arrow.Internals.ArrowAddError ex a a' => Control.Arrow.Internals.ArrowAddError ex (Control.Arrow.Transformer.Reader.ReaderArrow r a) (Control.Arrow.Transformer.Reader.ReaderArrow r a') instance Control.Arrow.Internals.ArrowAddState s a a' => Control.Arrow.Internals.ArrowAddState s (Control.Arrow.Transformer.Reader.ReaderArrow r a) (Control.Arrow.Transformer.Reader.ReaderArrow r a') instance Control.Arrow.Internals.ArrowAddWriter s a a' => Control.Arrow.Internals.ArrowAddWriter s (Control.Arrow.Transformer.Reader.ReaderArrow r a) (Control.Arrow.Transformer.Reader.ReaderArrow r a') instance Control.Arrow.Arrow a => GHC.Base.Functor (Control.Arrow.Transformer.Reader.ReaderArrow r a b) instance Control.Arrow.Arrow a => GHC.Base.Applicative (Control.Arrow.Transformer.Reader.ReaderArrow r a b) instance Control.Arrow.ArrowPlus a => GHC.Base.Alternative (Control.Arrow.Transformer.Reader.ReaderArrow r a b) instance Control.Arrow.ArrowPlus a => Data.Semigroup.Semigroup (Control.Arrow.Transformer.Reader.ReaderArrow r a b c) instance Control.Arrow.ArrowPlus a => GHC.Base.Monoid (Control.Arrow.Transformer.Reader.ReaderArrow r a b c) -- | An arrow transformer that adds a modifiable state, based of section 9 -- of Generalising Monads to Arrows, by John Hughes, Science of -- Computer Programming 37:67-111, May 2000. module Control.Arrow.Transformer.State -- | An arrow type that augments an existing arrow with a modifiable state. -- The ArrowState class contains the operations on this state. newtype StateArrow s a b c StateArrow :: (a (b, s) (c, s)) -> StateArrow s a b c -- | Encapsulation of a state-using computation, exposing the initial and -- final states. -- -- Typical usage in arrow notation: -- --
-- proc p -> do -- ... -- (result, final_state) <- (|runState cmd|) init_state --runState :: Arrow a => StateArrow s a e b -> a (e, s) (b, s) -- | Adding a StateArrow to an arrow type, but not necessarily as -- the outer arrow transformer. -- -- Typically a composite arrow type is built by applying a series of -- arrow transformer to a base arrow (usually either a function arrow or -- a Kleisli arrow. One can add a transformer to the top of this -- stack using the lift method of the ArrowTransformer -- class, or remove a state transformer from the top of the stack using -- the runState encapsulation operator. The methods of this class -- add and remove state transformers anywhere in the stack. In the -- instance -- --
-- instance Arrow a => ArrowAddState s (ArrowState s a) a ---- -- they are equivalent to lift and runState respectively. -- Instances are lifted through other transformers with -- --
-- instance ArrowAddState s a a' => -- ArrowAddState s (FooArrow a) (FooArrow a') --class (ArrowState s a, Arrow a') => ArrowAddState s a a' | a -> a' -- | Lift a computation from an arrow to one with an added state. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- (|liftState cmd|) --liftState :: ArrowAddState s a a' => a' e b -> a e b -- | Elimination of a state transformer from a computation, exposing the -- initial and final states. -- -- Typical usage in arrow notation: -- --
-- proc p -> do -- ... -- (result, final_state) <- (|elimState cmd|) init_state --elimState :: ArrowAddState s a a' => a e b -> a' (e, s) (b, s) instance Control.Category.Category a => Control.Category.Category (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.Arrow a => Control.Arrow.Arrow (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.Arrow a => Control.Arrow.Transformer.ArrowTransformer (Control.Arrow.Transformer.State.StateArrow s) a instance Control.Arrow.Arrow a => Control.Arrow.Operations.ArrowState s (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.Arrow a => Control.Arrow.Internals.ArrowAddState s (Control.Arrow.Transformer.State.StateArrow s a) a instance Control.Arrow.ArrowZero a => Control.Arrow.ArrowZero (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.Operations.ArrowCircuit a => Control.Arrow.Operations.ArrowCircuit (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.Operations.ArrowError ex a => Control.Arrow.Operations.ArrowError ex (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.Operations.ArrowReader r a => Control.Arrow.Operations.ArrowReader r (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.Operations.ArrowWriter w a => Control.Arrow.Operations.ArrowWriter w (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.ArrowChoice a => Control.Arrow.ArrowChoice (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.ArrowApply a => Control.Arrow.ArrowApply (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.ArrowLoop a => Control.Arrow.ArrowLoop (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.ArrowPlus a => Control.Arrow.ArrowPlus (Control.Arrow.Transformer.State.StateArrow s a) instance Control.Arrow.Arrow a => GHC.Base.Functor (Control.Arrow.Transformer.State.StateArrow s a b) instance Control.Arrow.Arrow a => GHC.Base.Applicative (Control.Arrow.Transformer.State.StateArrow s a b) instance Control.Arrow.ArrowPlus a => GHC.Base.Alternative (Control.Arrow.Transformer.State.StateArrow s a b) instance Control.Arrow.ArrowPlus a => Data.Semigroup.Semigroup (Control.Arrow.Transformer.State.StateArrow s a b c) instance Control.Arrow.ArrowPlus a => GHC.Base.Monoid (Control.Arrow.Transformer.State.StateArrow s a b c) instance Control.Arrow.Internals.ArrowAddReader r a a' => Control.Arrow.Internals.ArrowAddReader r (Control.Arrow.Transformer.State.StateArrow s a) (Control.Arrow.Transformer.State.StateArrow s a') instance Control.Arrow.Internals.ArrowAddWriter w a a' => Control.Arrow.Internals.ArrowAddWriter w (Control.Arrow.Transformer.State.StateArrow s a) (Control.Arrow.Transformer.State.StateArrow s a') instance Control.Arrow.Internals.ArrowAddError ex a a' => Control.Arrow.Internals.ArrowAddError ex (Control.Arrow.Transformer.State.StateArrow s a) (Control.Arrow.Transformer.State.StateArrow s a') -- | Arrow transformer adding static information. module Control.Arrow.Transformer.Static -- | An arrow type that augments the underlying arrow with static -- information. newtype StaticArrow f a b c StaticArrow :: (f (a b c)) -> StaticArrow f a b c -- | A special case is monads applied to the whole arrow, in contrast to -- Kleisli arrows, in which the monad is applied to the output. type StaticMonadArrow m = StaticArrow (WrappedMonad m) -- | A special case. type StaticArrowArrow a s = StaticArrow (WrappedArrow a s) wrap :: (Applicative f, Arrow a) => f (a b c) -> StaticArrow f a b c unwrap :: (Applicative f, Arrow a) => StaticArrow f a b c -> f (a b c) wrapA :: (Arrow a, Arrow a') => a s (a' b c) -> StaticArrowArrow a s a' b c unwrapA :: (Arrow a, Arrow a') => StaticArrowArrow a s a' b c -> a s (a' b c) wrapM :: (Monad m, Arrow a) => m (a b c) -> StaticMonadArrow m a b c unwrapM :: (Monad m, Arrow a) => StaticMonadArrow m a b c -> m (a b c) instance (Control.Arrow.Arrow a, GHC.Base.Applicative f) => Control.Arrow.Transformer.ArrowTransformer (Control.Arrow.Transformer.Static.StaticArrow f) a instance (Control.Category.Category a, GHC.Base.Applicative f) => Control.Category.Category (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.Arrow a, GHC.Base.Applicative f) => Control.Arrow.Arrow (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.ArrowZero a, GHC.Base.Applicative f) => Control.Arrow.ArrowZero (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.Operations.ArrowCircuit a, GHC.Base.Applicative f) => Control.Arrow.Operations.ArrowCircuit (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.Operations.ArrowError ex a, GHC.Base.Applicative f) => Control.Arrow.Operations.ArrowError ex (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.Operations.ArrowReader r a, GHC.Base.Applicative f) => Control.Arrow.Operations.ArrowReader r (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.Operations.ArrowState s a, GHC.Base.Applicative f) => Control.Arrow.Operations.ArrowState s (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.Operations.ArrowWriter w a, GHC.Base.Applicative f) => Control.Arrow.Operations.ArrowWriter w (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.ArrowChoice a, GHC.Base.Applicative f) => Control.Arrow.ArrowChoice (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.ArrowLoop a, GHC.Base.Applicative f) => Control.Arrow.ArrowLoop (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.ArrowPlus a, GHC.Base.Applicative f) => Control.Arrow.ArrowPlus (Control.Arrow.Transformer.Static.StaticArrow f a) instance (Control.Arrow.Arrow a, GHC.Base.Applicative f) => GHC.Base.Functor (Control.Arrow.Transformer.Static.StaticArrow f a b) instance (Control.Arrow.Arrow a, GHC.Base.Applicative f) => GHC.Base.Applicative (Control.Arrow.Transformer.Static.StaticArrow f a b) instance (Control.Arrow.ArrowPlus a, GHC.Base.Applicative f) => GHC.Base.Alternative (Control.Arrow.Transformer.Static.StaticArrow f a b) instance (Control.Arrow.ArrowPlus a, GHC.Base.Applicative f) => Data.Semigroup.Semigroup (Control.Arrow.Transformer.Static.StaticArrow f a b c) instance (Control.Arrow.ArrowPlus a, GHC.Base.Applicative f) => GHC.Base.Monoid (Control.Arrow.Transformer.Static.StaticArrow f a b c) instance (Control.Arrow.Internals.ArrowAddStream a a', GHC.Base.Applicative f) => Control.Arrow.Internals.ArrowAddStream (Control.Arrow.Transformer.Static.StaticArrow f a) (Control.Arrow.Transformer.Static.StaticArrow f a') instance (Control.Arrow.Internals.ArrowAddState s a a', GHC.Base.Applicative f) => Control.Arrow.Internals.ArrowAddState s (Control.Arrow.Transformer.Static.StaticArrow f a) (Control.Arrow.Transformer.Static.StaticArrow f a') instance (Control.Arrow.Internals.ArrowAddReader r a a', GHC.Base.Applicative f) => Control.Arrow.Internals.ArrowAddReader r (Control.Arrow.Transformer.Static.StaticArrow f a) (Control.Arrow.Transformer.Static.StaticArrow f a') instance (Control.Arrow.Internals.ArrowAddWriter w a a', GHC.Base.Applicative f) => Control.Arrow.Internals.ArrowAddWriter w (Control.Arrow.Transformer.Static.StaticArrow f a) (Control.Arrow.Transformer.Static.StaticArrow f a') instance (Control.Arrow.Internals.ArrowAddError ex a a', GHC.Base.Applicative f) => Control.Arrow.Internals.ArrowAddError ex (Control.Arrow.Transformer.Static.StaticArrow f a) (Control.Arrow.Transformer.Static.StaticArrow f a') -- | Arrow transformer lifting an arrow to streams. module Control.Arrow.Transformer.Stream -- | Arrows between streams. -- -- Note: lift is only a functor if *** in the -- underlying arrow is. newtype StreamArrow a b c StreamArrow :: (a (Stream b) (Stream c)) -> StreamArrow a b c -- | Run a stream processor on a stream of inputs, obtaining a stream of -- outputs. -- -- Typical usage in arrow notation: -- --
-- proc p -> do -- ... -- ys <- (|runStream (\x -> ...)|) xs ---- -- Here xs refers to the input stream and x to -- individual elements of that stream. ys is bound to the output -- stream. runStream :: ArrowLoop a => StreamArrow a (e, b) c -> a (e, Stream b) (Stream c) -- | Mappings of streams type StreamMap = StreamArrow (->) -- | In-place state updates. -- -- Note: this is an arrow type, and lift can be used to -- promote arrows from Kleisli (ST s): the -- resulting arrow updates the state for each stream element in turn, and -- as long as the final state in not required all is well. However, -- lift does not preserve composition, because this monad isn't -- commutative. In particular, a composition of lifts of state -- transformers will not work, as the second will require the final state -- of the first. type StreamMapST s = StreamArrow (Kleisli (ST s)) -- | Encapsulate a local state. runStreamST :: (forall s. StreamMapST s e c) -> StreamMap e c -- | Adding a StreamArrow to an arrow type, but not necessarily as -- the outer arrow transformer. -- -- Typically a composite arrow type is built by applying a series of -- arrow transformer to a base arrow (usually either a function arrow or -- a Kleisli arrow. One can add a transformer to the top of this -- stack using the lift method of the ArrowTransformer -- class, or remove a state transformer from the top of the stack using -- the runStream encapsulation operator. The methods of this class -- add and remove state transformers anywhere in the stack. In the -- instance -- --
-- instance Arrow a => ArrowAddStream (ArrowStream a) a ---- -- they are equivalent to lift and runStream respectively. -- Instances are lifted through other transformers with -- --
-- instance ArrowAddStream a a' => -- ArrowAddStream (FooArrow a) (FooArrow a') --class (ArrowCircuit a, Arrow a') => ArrowAddStream a a' | a -> a' -- | Lift a computation from an arrow to a stream processing one. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- (|liftStream cmd|) --liftStream :: ArrowAddStream a a' => a' e b -> a e b -- | Run a stream processor on a stream of inputs, obtaining a stream of -- outputs. -- -- Typical usage in arrow notation: -- --
-- proc p -> do -- ... -- ys <- (|elimStream (\x -> ...)|) xs ---- -- Here xs refers to the input stream and x to -- individual elements of that stream. ys is bound to the output -- stream. elimStream :: ArrowAddStream a a' => a (e, b) c -> a' (e, Stream b) (Stream c) instance Control.Category.Category a => Control.Category.Category (Control.Arrow.Transformer.Stream.StreamArrow a) instance Control.Arrow.Arrow a => Control.Arrow.Arrow (Control.Arrow.Transformer.Stream.StreamArrow a) instance Control.Arrow.Arrow a => Control.Arrow.Transformer.ArrowTransformer Control.Arrow.Transformer.Stream.StreamArrow a instance Control.Arrow.ArrowZero a => Control.Arrow.ArrowZero (Control.Arrow.Transformer.Stream.StreamArrow a) instance Control.Arrow.Operations.ArrowState s a => Control.Arrow.Operations.ArrowState s (Control.Arrow.Transformer.Stream.StreamArrow a) instance Control.Arrow.Operations.ArrowWriter w a => Control.Arrow.Operations.ArrowWriter w (Control.Arrow.Transformer.Stream.StreamArrow a) instance Control.Arrow.Arrow a => Control.Arrow.ArrowChoice (Control.Arrow.Transformer.Stream.StreamArrow a) instance Control.Arrow.ArrowLoop a => Control.Arrow.ArrowLoop (Control.Arrow.Transformer.Stream.StreamArrow a) instance Control.Arrow.ArrowPlus a => Control.Arrow.ArrowPlus (Control.Arrow.Transformer.Stream.StreamArrow a) instance Control.Arrow.ArrowLoop a => Control.Arrow.Operations.ArrowCircuit (Control.Arrow.Transformer.Stream.StreamArrow a) instance Control.Arrow.Arrow a => GHC.Base.Functor (Control.Arrow.Transformer.Stream.StreamArrow a b) instance Control.Arrow.Arrow a => GHC.Base.Applicative (Control.Arrow.Transformer.Stream.StreamArrow a b) instance Control.Arrow.ArrowPlus a => GHC.Base.Alternative (Control.Arrow.Transformer.Stream.StreamArrow a b) instance Control.Arrow.ArrowPlus a => Data.Semigroup.Semigroup (Control.Arrow.Transformer.Stream.StreamArrow a b c) instance Control.Arrow.ArrowPlus a => GHC.Base.Monoid (Control.Arrow.Transformer.Stream.StreamArrow a b c) instance Control.Arrow.ArrowLoop a => Control.Arrow.Internals.ArrowAddStream (Control.Arrow.Transformer.Stream.StreamArrow a) a -- | Arrow transformer that adds accumulation of output. module Control.Arrow.Transformer.Writer -- | An arrow type that augments an existing arrow with accumulating -- output. The ArrowWriter class contains the relevant operations. newtype WriterArrow w a b c WriterArrow :: (a b (c, w)) -> WriterArrow w a b c -- | Encapsulation of a writer computation, providing the accumulated -- output. -- -- Typical usage in arrow notation: -- --
-- proc p -> do -- ... -- (result, output) <- (|runWriter cmd|) --runWriter :: (Arrow a, Monoid w) => WriterArrow w a e b -> a e (b, w) -- | Adding a WriterArrow to an arrow type, but not necessarily as -- the outer arrow transformer. -- -- Typically a composite arrow type is built by applying a series of -- arrow transformer to a base arrow (usually either a function arrow or -- a Kleisli arrow. One can add a transformer to the top of this -- stack using the lift method of the ArrowTransformer -- class, or remove a state transformer from the top of the stack using -- the runWriter encapsulation operator. The methods of this class -- add and remove state transformers anywhere in the stack. In the -- instance -- --
-- instance Arrow a => ArrowAddWriter w (ArrowWriter w a) a ---- -- they are equivalent to lift and runWriter respectively. -- Instances are lifted through other transformers with -- --
-- instance ArrowAddWriter w a a' => -- ArrowAddWriter w (FooArrow a) (FooArrow a') --class (ArrowWriter w a, Arrow a') => ArrowAddWriter w a a' | a -> a' -- | Lift a computation from an arrow to one with added output. -- -- Typical usage in arrow notation: -- --
-- proc p -> ... -- (|liftWriter cmd|) --liftWriter :: ArrowAddWriter w a a' => a' e b -> a e b -- | Elimination of an output writer from a computation, providing the -- accumulated output. -- -- Typical usage in arrow notation: -- --
-- proc p -> do -- ... -- (result, output) <- (|elimWriter cmd|) --elimWriter :: ArrowAddWriter w a a' => a e b -> a' e (b, w) instance (Control.Arrow.Arrow a, GHC.Base.Monoid w) => Control.Arrow.Transformer.ArrowTransformer (Control.Arrow.Transformer.Writer.WriterArrow w) a instance (Control.Arrow.Arrow a, GHC.Base.Monoid w) => Control.Category.Category (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.Arrow a, GHC.Base.Monoid w) => Control.Arrow.Arrow (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.ArrowChoice a, GHC.Base.Monoid w) => Control.Arrow.ArrowChoice (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.ArrowApply a, GHC.Base.Monoid w) => Control.Arrow.ArrowApply (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.ArrowZero a, GHC.Base.Monoid w) => Control.Arrow.ArrowZero (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.ArrowPlus a, GHC.Base.Monoid w) => Control.Arrow.ArrowPlus (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.ArrowLoop a, GHC.Base.Monoid w) => Control.Arrow.ArrowLoop (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.Arrow a, GHC.Base.Monoid w) => GHC.Base.Functor (Control.Arrow.Transformer.Writer.WriterArrow w a b) instance (Control.Arrow.Arrow a, GHC.Base.Monoid w) => GHC.Base.Applicative (Control.Arrow.Transformer.Writer.WriterArrow w a b) instance (Control.Arrow.ArrowPlus a, GHC.Base.Monoid w) => GHC.Base.Alternative (Control.Arrow.Transformer.Writer.WriterArrow w a b) instance (Control.Arrow.ArrowPlus a, GHC.Base.Monoid w) => Data.Semigroup.Semigroup (Control.Arrow.Transformer.Writer.WriterArrow w a b c) instance (Control.Arrow.ArrowPlus a, GHC.Base.Monoid w) => GHC.Base.Monoid (Control.Arrow.Transformer.Writer.WriterArrow w a b c) instance (Control.Arrow.Arrow a, GHC.Base.Monoid w) => Control.Arrow.Operations.ArrowWriter w (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.Arrow a, GHC.Base.Monoid w) => Control.Arrow.Internals.ArrowAddWriter w (Control.Arrow.Transformer.Writer.WriterArrow w a) a instance (Control.Arrow.Operations.ArrowCircuit a, GHC.Base.Monoid w) => Control.Arrow.Operations.ArrowCircuit (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.Operations.ArrowError ex a, GHC.Base.Monoid w) => Control.Arrow.Operations.ArrowError ex (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.Operations.ArrowReader r a, GHC.Base.Monoid w) => Control.Arrow.Operations.ArrowReader r (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.Operations.ArrowState s a, GHC.Base.Monoid w) => Control.Arrow.Operations.ArrowState s (Control.Arrow.Transformer.Writer.WriterArrow w a) instance (Control.Arrow.Internals.ArrowAddError ex a a', GHC.Base.Monoid w) => Control.Arrow.Internals.ArrowAddError ex (Control.Arrow.Transformer.Writer.WriterArrow w a) (Control.Arrow.Transformer.Writer.WriterArrow w a') instance (Control.Arrow.Internals.ArrowAddReader r a a', GHC.Base.Monoid w) => Control.Arrow.Internals.ArrowAddReader r (Control.Arrow.Transformer.Writer.WriterArrow w a) (Control.Arrow.Transformer.Writer.WriterArrow w a') instance (Control.Arrow.Internals.ArrowAddState s a a', GHC.Base.Monoid w) => Control.Arrow.Internals.ArrowAddState s (Control.Arrow.Transformer.Writer.WriterArrow w a) (Control.Arrow.Transformer.Writer.WriterArrow w a') module Control.Arrow.Transformer.All