Safe Haskell  Safe 

Language  Haskell2010 
Monadic Stream Functions are synchronized stream functions with side effects.
MSF
s are defined by a function
unMSF :: MSF m a b > a > m (b, MSF m a b)
that executes one step of a simulation, and produces an output in a
monadic context, and a continuation to be used for future steps.
MSF
s are a generalisation of the implementation mechanism used by Yampa,
Wormholes and other FRP and reactive implementations.
This modules defines only the minimal core. Hopefully, other functions can be defined in terms of the functions in this module without accessing the MSF constuctor.
Definitions
Stepwise, sideeffectful MSF
s without implicit knowledge of time.
MSF
s should be applied to streams or executed indefinitely or until they
terminate. See reactimate
and reactimateB
for details. In general,
calling the value constructor MSF
or the function unMSF
is discouraged.
Instances
Monad m => Arrow (MSF m) Source #  
(Monad m, MonadPlus m) => ArrowZero (MSF m) Source #  Instance of 
(Monad m, MonadPlus m) => ArrowPlus (MSF m) Source #  Instance of 
Monad m => ArrowChoice (MSF m) Source # 

MonadFix m => ArrowLoop (MSF m) Source # 

Monad m => Category (MSF m :: Type > Type > Type) Source #  
Monad m => Functor (MSF m a) Source #  
(Functor m, Monad m) => Applicative (MSF m a) Source # 

(Functor m, Monad m, MonadPlus m) => Alternative (MSF m a) Source #  
(Monad m, Floating b) => Floating (MSF m a b) Source #  
Defined in Data.MonadicStreamFunction.Instances.Num exp :: MSF m a b > MSF m a b # log :: MSF m a b > MSF m a b # sqrt :: MSF m a b > MSF m a b # (**) :: MSF m a b > MSF m a b > MSF m a b # logBase :: MSF m a b > MSF m a b > MSF m a b # sin :: MSF m a b > MSF m a b # cos :: MSF m a b > MSF m a b # tan :: MSF m a b > MSF m a b # asin :: MSF m a b > MSF m a b # acos :: MSF m a b > MSF m a b # atan :: MSF m a b > MSF m a b # sinh :: MSF m a b > MSF m a b # cosh :: MSF m a b > MSF m a b # tanh :: MSF m a b > MSF m a b # asinh :: MSF m a b > MSF m a b # acosh :: MSF m a b > MSF m a b # atanh :: MSF m a b > MSF m a b # log1p :: MSF m a b > MSF m a b # expm1 :: MSF m a b > MSF m a b #  
(Monad m, Fractional b) => Fractional (MSF m a b) Source # 

(Monad m, Num b) => Num (MSF m a b) Source #  
Defined in Data.MonadicStreamFunction.Instances.Num  
(Monad m, VectorSpace v) => VectorSpace (MSF m a v) Source #  Vectorspace instance for 
(Monad m, RModule v) => RModule (MSF m a v) Source #  Rmodule instance for 
Defined in Data.MonadicStreamFunction.Instances.VectorSpace type Groundring (MSF m a v) :: Type Source #  
type Groundring (MSF m a v) Source #  
Monadic computations and
MSF
s
:: Monad m2  
=> (forall c. (a1 > m1 (b1, c)) > a2 > m2 (b2, c))  The natural transformation. 
> MSF m1 a1 b1  
> MSF m2 a2 b2 
Generic lifting of a morphism to the level of MSF
s.
Natural transformation to the level of MSF
s.
Mathematical background: The type a > m (b, c)
is a functor in c
,
and MSF m a b
is its greatest fixpoint, i.e. it is isomorphic to the type
a > m (b, MSF m a b)
, by definition.
The types m
, a
and b
are parameters of the functor.
Taking a fixpoint is functorial itself, meaning that a morphism
(a natural transformation) of two such functors gives a morphism
(an ordinary function) of their fixpoints.
This is in a sense the most general "abstract" lifting function,
i.e. the most general one that only changes input, output and side effect
types, and doesn't influence control flow.
Other handling functions like exception handling or ListT
broadcasting
necessarily change control flow.
Feedback loops
feedback :: Monad m => c > MSF m (a, c) (b, c) > MSF m a b Source #
Wellformed looped connection of an output component as a future input.
Execution/simulation
embed :: Monad m => MSF m a b > [a] > m [b] Source #
Apply a monadic stream function to a list.
Because the result is in a monad, it may be necessary to
traverse the whole list to evaluate the value in the results to WHNF.
For example, if the monad is the maybe monad, this may not produce anything
if the MSF
produces Nothing
at any point, so the output stream cannot
consumed progressively.
To explore the output progressively, use liftMSF
and '(>>>)'', together
with some action that consumes/actuates on the output.
This is called runSF
in Liu, Cheng, Hudak, "Causal Commutative Arrows and
Their Optimization"