machinecell: Arrow based stream transducers

[ bsd3, control, frp, library, reactivity ] [ Propose Tags ] [ Report a vulnerability ]

Stream processing library similar to pipes, couduit, or machines.

Arrow combinatins are supported and can be used with the arrow notation. AFRP-like utilities are also available.

A quick introduction is available in the Control.Arrow.Machine documentation.


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
arrow-tr

Arrow transformer support.

A few environments(stackage, haste, etc) don't support this package.

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.3.0, 1.3.1, 2.0.0, 2.0.1, 2.1.0, 3.0.0, 3.0.1, 3.1.0, 3.2.0, 3.3.0, 3.3.1, 3.3.2, 4.0.0, 4.0.1
Change log CHANGELOG.md
Dependencies base (>=4.8 && <5.0), free (>=4.12.3 && <5.1), mtl (>=2.2.1 && <3), profunctors (>=5.2 && <6), semigroups (>=0.18.1 && <1), transformers (>=0.5.0.0 && <1) [details]
License BSD-3-Clause
Copyright Copyright (c) 2014 Hidenori Azuma
Author Hidenori Azuma
Maintainer Hidenori Azuma <as.capabl@gmail.com>
Category Control, FRP, Reactivity
Home page http://github.com/as-capabl/machinecell
Bug tracker http://github.com/as-capabl/machinecell/issues
Source repo head: git clone https://github.com/as-capabl/machinecell.git -b master
this: git clone https://github.com/as-capabl/machinecell.git(tag release-4.0.1)
Uploaded by HidenoriAzuma at 2018-04-17T16:35:11Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 13137 total (47 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-04-17 [all 1 reports]

Readme for machinecell-4.0.1

[back to package description]

machinecell

Arrow based stream transducer.

Description

As other iteratee or pipe libraries, machinecell abstracts general iteration processes.

Here is an example that is a simple iteration over a list.

>>> run (evMap (+1)) [1, 2, 3]
[2, 3, 4]

In above statement, "evMap (+1)" has a type "ProcessA (->) (Event Int) (Event Int)", which denotes "A stream transducer that takes a series of Int as input, gives a series of Int as output, run on base arrow (->)."

In addition to this simple iteration, machinecell has following features.

  • Side effects
  • Composite pipelines
  • Arrow compositions
  • Behaviours and switches

See Control.Arrow.Machine documentation.

Comparison to other libraries.

Some part of machinecell is similar to other stream transducer libraries, namely pipes, conduit, or machines. machinecell can be seen as a restricted variation of them to one-directional. But additionally, machinecell supports arrow compositions. Bidirectional communications can be taken place by ArrowLoop feature.

Rather, there are several other arrowised stream transducer libraries. streamproc shares the most concept to machinecell. But actually it has a problem described later in this post. Machinecell can be said as "Streamproc done right."

auto is a brand-new arrowised stream transducer library. Compared to it, machinecell's advantage is await/yield coroutines, while auto's one is serialization.

Motivation and background

"Generalizing monads to arrows," The original paper of arrow calculation mentions a kind of stream transducer, which later implemented as streamproc.

http://www.cse.chalmers.se/~rjmh/Papers/arrows.pdf

And other people propose instance declarations of Arrow class for several existing stream processors.

http://stackoverflow.com/questions/19758744/haskell-splitting-pipes-broadcast-without-using-spawn

https://www.fpcomplete.com/school/to-infinity-and-beyond/pick-of-the-week/coroutines-for-streaming/part-4-category-and-arrow

But actually, there is a problem argued in this post.

https://mail.haskell.org/pipermail/haskell-cafe/2010-January/072193.html

The core problem is, while arrow uses tuples as parallel data stream, they cannot represent a composite streams if they carry different numbers of data in parallel.

To solve this problem, some arrow libraries restrict transducers to one-to-one data transformation. Yampa and netwire does so, as mentioned in above post. And auto also takes this approach.

Machinecell's approach is different, but simple too. The key idea is wrapping all types of data stream into a maybe-like type. Then even tuples can represent different numbers of data, by inserting appropreate number of 'Nothing's.

Furthermore, I identified the maybe-like type as the 'Event' type, which appears in Yampa and netwire. Then I successively implemented several arrows of Yampa and netwire.

API names come from stream libraries are named after machines', while ones from FRPs are after Yampa's. Now, machinecell may be seen as a hybrid of machines and Yampa.