churros: Channel/Arrow based streaming computation library.

[ control, data, library, mit ] [ Propose Tags ]

The Churro library takes an opinionated approach to streaming by focusing on IO processes and allowing different transport options.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.1.0, 0.1.2.0, 0.1.3.0, 0.1.4.0, 0.1.4.1, 0.1.5.0, 0.1.6.0
Change log CHANGELOG.md
Dependencies async, base (>=4.10 && <4.17), containers, random, stm, time, unagi-chan [details]
License MIT
Author Lyndon Maydwell
Maintainer lyndon@sordina.net
Category Data, Control
Home page http://github.com/sordina/churros
Bug tracker http://github.com/sordina/churros/issues
Source repo head: git clone git@github.com:sordina/churros.git
Uploaded by LyndonMaydwell at 2022-10-16T05:18:49Z
Distributions
Downloads 1339 total (24 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for churros-0.1.6.0

[back to package description]

Churros

Chan + Arrow = Churro

Simple alternative to Conduit, Pipes, Streaming, Machines, etc.

Use-case is CSP like scenarios where you need a graph of actors.

Signup Example:

New-Users -->  Validate -------?----->  Deploy  -----?--------------> Log
Subscribe    REST Request      |      Run Server     |         Write File
{-> ID}    {ID -> (ID,Email}   |    {Email -> Port}  |  {Port|Receipt ->}
                               |                     |
                               +-------> Warn -------+
                                      Send Email
                                  {Email -> Receipt}

Developed from a history of attempting to use co-routines libraries for setting up complicated asynchronous processes such as collections of MIDI instruments, etc, but being frustrated by not easily being able to conditionally consume and emit events. In these situations I'd fall back on creating a bunch of Chans and piping events manually. Churros just formalises that strategy to help you get it right!

Advantages over other alternatives:

  • Focus on IO processes
  • Dynamic choice of consumption/production
  • Arrow instance
  • Choice of transport via the Transport class

Disadvantages:

  • No pure interface!
  • Type for the async action restricted to Monoid for most operations.
  • Limited ability to perform lock-step computation (although this is by design)

See Hackage for more info!

Examples

See ./test/ directory for more extensive examples.

import Control.Churro

main = do
   runWaitChan             $ sourceList [1..10] >>> processDebug "after source" >>> delay 1 {- seconds -} >>> arr succ >>> sinkPrint
   (wait =<<)  $ run @Chan $ sourceIO (\cb -> cb 1 >> print "Doing whatever!" >> cb 5) >>> filterC (> 3) >>> sinkIO print

Testing

Cabal test-suite including doctests:

cabal exec cabal test

Or for itterative development:

find {src,test} | entr -- cabal exec -- doctest -isrc -itest test/Churro/Test/Examples.hs

TODO

  • Add seperate projects to allow minimal core and enciched ecosystem e.g. churros-unagi
  • Create profunctor instance
  • Create contravariant functor instance
  • Create ArrowChoice instance
  • Create ArrowLoop instance
  • Different transports for sections of the graph
  • Allow configurable parallelism / Pool Churro functions
  • Recovery/Retry capability
  • Fix await deadlock
  • Generic Chan functions, then specific newtype
  • Stop using list functions
  • Different transport options, buffered, etc.
  • Write doctests for functionality
  • Get Doctests working as part of the cabal test-suite
  • Bundle in/out channels in the Transport class to allow Unagi to implement it
  • Allow returning of results from run functions
  • Get haddocks rendering correctly - Including contents
  • Early termination if downstream consumer completes
    • Ensure that infinite lists work when partially consumed