[Haskell-cafe] Arrows and streaming/piping

MarLinn monkleyon at gmail.com
Wed Nov 22 19:39:05 UTC 2017

Hi Paul.

> There is a statement that Arrows can be used as streaming approach. 
> Arrows are very new for me, so my question may looks stupid, but would 
> somebody show me clean and simple example how it will look? Lets 
> suppose we have function `getLines` which returns `IO [String]`, a lot 
> of lines :) And I want to process them as I do it with streaming 
> library (or pipes) - with constant space.
> If it's true, then I can use Arrows instead of pipes, right?

No. Or rather maybe. But mostly no. Arrows are just a particular way to 
write and think about code. You can structure a library to be 
particularly well suited to arrows, but what a library does and how you 
use it is completely orthogonal. When people say arrows are suitable for 
a streaming approach, what they often mean is that thinking in terms of 
arrows and thinking in terms of streams are compatible.

That means that no amount of arrows will help you stream your data. And 
if you use a streaming library that's optimised for arrows, you can 
forego the arrows if you want.

In fact arrows have fallen out of favour with most Haskell programmers 
because (1) you can get almost all their advantages with just 
Applicatives and (2) many things Arrow syntax would be great for can't 
be implemented with how the Arrow hierarchy is currently structured and 
desugared. For that reason I don't think any modern streaming library 
will rely on arrows.

That being said, to help you with the need for streams, might I point 
you to the excellent conduit-library. It's a bit complex to learn, but 
their github (https://github.com/snoyberg/conduit) has a rather 
impressive introduction.


More information about the Haskell-Cafe mailing list