Idris2Doc : Data.MSF.Core

Data.MSF.Core

(source)
Provides a data type for Monadic Stream Functions (MSFs)
together with associated interface implementations and
some core functionality.

An MSF is an effectful computation from an input of type `i`
to an output of type `o`, that can be described using a rich
library of combinators and evaluated using function
`Data.MSF.Running.step`,
which not only produces an output for every input value
but also a new MSF to be used in the next evaluation step.

Reexports

import public Data.MSF.Event

Definitions

0 FanList : (Type -> Type) -> Type -> List Type -> Type
  A heterogeneous list of MSFs all of which
accept the same input type. This is used for
broadcasting an input value across several MSFs,
collecting the result as an n-ary product.
See also function `fan`.

Totality: total
Visibility: public export
0 CollectList : (Type -> Type) -> List Type -> Type -> Type
  A heterogeneous list of MSFs all of which
produce the same type of outup. This is used for
choosing a single MSF for producing a result based
on an n-ary sum as input. See also function `collect`.

Totality: total
Visibility: public export
data ParList : (Type -> Type) -> List Type -> List Type -> Type
  A heterogeneous list of MSFs. This is used both
for running several unrelated MSFs in parallel, in
which case it takes an n-ary product as input
and produces an n-ary product as output (see
function `par`), as well as for selecting a single
MSF to run based on an n-ary sum as input, in which
case a value of an n-ary sum is produced as output
(see function `choice` for this use case).

Totality: total
Visibility: public export
Constructors:
Nil : ParList m [] []
(::) : MSF m i o -> ParList m is os -> ParList m (i :: is) (o :: os)
data MSF : (Type -> Type) -> Type -> Type -> Type
Totality: total
Visibility: public export
Constructors:
Id : MSF m i i
  The identity MSF
Const : o -> MSF m i o
  The constant MSF
Arr : (i -> o) -> MSF m i o
  Lifts a pure function to an MSF
Lifted : (i -> m o) -> MSF m i o
  Lifts an effectful computation to an MSF
Seq : MSF m i x -> MSF m x o -> MSF m i o
  Sequencing of MSFs
Par : ParList m is os -> MSF m (HList is) (HList os)
  Parallelising MSFs
Fan : FanList m i os -> MSF m i (HList os)
  Broadcasting a value to a list of MSFs
all taking the same input
Choice : ParList m is os -> MSF m (HSum is) (HSum os)
  Choosing an MSF based on an n-ary sum as input
Collect : CollectList m is o -> MSF m (HSum is) o
  Choosing an MSF (all of which produce the same output)
based on an n-ary sum as input
Loop : s -> MSF m (HList [s, i]) (HList [s, o]) -> MSF m i o
  Feedback loops (stateful computations)
Switch : MSF m i (Either e o) -> (e -> MSF m i o) -> MSF m i o
  Single time switching: Upon the first event,
the second stream function is calculated,
evaluated immediately and used henceforth.

Hints:
Applicative (MSF m i)
Fractional o => Fractional (MSF m i o)
FromString o => FromString (MSF m i o)
Functor (MSF m i)
Integral o => Integral (MSF m i o)
Monoid o => Monoid (MSF m i o)
Neg o => Neg (MSF m i o)
Num o => Num (MSF m i o)
Semigroup o => Semigroup (MSF m i o)
id : MSF m i i
  The identity MSF

Totality: total
Visibility: export
const : o -> MSF m i o
  A constant MSF

Totality: total
Visibility: export
arr : (i -> o) -> MSF m i o
  Lifting a pure function to an MSF

Totality: total
Visibility: export
arrM : (i -> m o) -> MSF m i o
  Lifting an effectful computation to an MSF

Totality: total
Visibility: export
constM : m o -> MSF m i o
  Lifting a value in a context to an MSF

Totality: total
Visibility: export
(>>>) : MSF m i x -> MSF m x o -> MSF m i o
  Sequencing of MSFs

Totality: total
Visibility: export
Fixity Declaration: infixr operator, level 1
par : ParList m is os -> MSF m (HList is) (HList os)
  Runs a bundle of MSFs in parallel. This is
a generalization of `(***)` from `Control.Arrow`.

Totality: total
Visibility: export
fan : FanList m i os -> MSF m i (HList os)
  Broadcasts an input value across a list of MSFs,
all of which must accept the same type of input.
This is a generalization of `(&&&)` from `Control.Arrow`.

Totality: total
Visibility: export
elementwise2 : (o1 -> o2 -> o3) -> MSF m i o1 -> MSF m i o2 -> MSF m i o3
  Apply a binary function to the result of running
two MSFs in parallel.

Totality: total
Visibility: export
choice : ParList m is os -> MSF m (HSum is) (HSum os)
  Choose an MSF to run depending the input value
This is a generalization of `(+++)` from `Control.Arrow`.

Totality: total
Visibility: export
collect : CollectList m is o -> MSF m (HSum is) o
  Choose an MSF all of which produce the same output.
This is a generalization of `(\|/)` from `Control.Arrow`.

Totality: total
Visibility: export
feedback : s -> MSF m (HList [s, i]) (HList [s, o]) -> MSF m i o
  Feedback loops: Given an initial state value,
we can feedback the result of each evaluation
step and us it as the new state for the next step.

Totality: total
Visibility: export