machinecell: Arrow based stream transducers

[ bsd3, control, frp, library, reactivity ] [ Propose Tags ]

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.

Enabled

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 arrows (>=0.4.3.0), base (>=4.6.0.0 && <5.0), free (>=4.12), mtl (>=2.2), profunctors (>=4.0.4), semigroups (>=0.8.3.1), transformers (>=0.4 && <0.5) [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-3.3.1)
Uploaded by HidenoriAzuma at 2016-12-20T15:15:22Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 12881 total (46 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user [build log]
All reported builds failed as of 2016-12-20 [all 3 reports]

Readme for machinecell-3.3.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.