`pipes` is a group of libraries written in Haskell to provide safe, functional, and strict I/O.
Questions tagged [haskell-pipes]
139 questions
3
votes
1 answer
Handling sum encoding in Streaming libraries
The motivation behind this question is this scenario - we have a stream of values which are represented by a Sum encoding. Let us assume Either ByteString ByteString where we represent streams of bytes in error and good states respectively. Now, we…

Sal
- 4,312
- 1
- 17
- 26
3
votes
1 answer
Idiomatic prefetching in a streaming library
I'm working with the streaming library but would accept an answer using pipes or conduit.
Say I have
import Streaming (Stream, Of)
import qualified Streaming.Prelude as S
streamChunks :: Int -> Stream (Of Thing) IO ()
streamChunks lastID = do
…

jberryman
- 16,334
- 5
- 42
- 83
3
votes
1 answer
Pipes unfolds composition
I am currently in the process of learning pipes. While playing around with bidirectional pipes I noticed that unfold composition looks pretty similar:
(//>) :: Monad m => Proxy x' x b' b m r -> (b -> Proxy x' x c' c m b') -> Proxy x' x c' c m r
--…

Taren
- 674
- 5
- 11
3
votes
1 answer
How can I make a Pipe concurrent with Haskell's Pipe library?
I have some Haskell code that uses Pipes:
module Main(main) where
import Pipes
a :: Producer Int IO ()
a = each [1..10]
b :: Pipe Int Int IO ()
b = do
x <- await
yield (x*2)
b
c :: Consumer Int IO ()
c = do
x <- await
lift $ print x
…

Buttons840
- 9,239
- 15
- 58
- 85
3
votes
1 answer
Reading first row from a csv file with pipes-csv
I am reading a csv file with pipes-csv library. I want to read first line and read the rest later. Unfortunately after Pipes.Prelude.head function returns. pipe is being closed somehow. Is there a way to read head of the csv first and read the rest…

yilmazhuseyin
- 6,442
- 4
- 34
- 38
3
votes
2 answers
Is there a standard abstraction for this request-response type?
I have the following type:
data S req rsp = Done rsp | Next req (rsp -> S req rsp)
The idea is to use it as a pure representation for network communication, i.e:
... Next GetUser $ \uid -> Next (Login uid) $ \success -> Done success
Which would…

Philip Kamenarsky
- 2,757
- 2
- 24
- 30
3
votes
0 answers
Pipes choice without pattern matching
This is closely related to Gabriel's response to another question. I have written a function that provides something like the ||| function from ArrowChoice but for a Proxy (from the pipes library). It pattern matches and has five mutually recursive…

Andrew Thaddeus Martin
- 3,225
- 17
- 37
3
votes
1 answer
Pipes: open a file according to content of another
I have this code:
import Pipes
import Pipes.Safe
import qualified Pipes.Prelude as P
import qualified Pipes.Safe.Prelude as P
import System.IO
import Data.Text as T
import Data.Text.IO as TIO
import qualified Pipes.Prelude.Text as T
someFunc :: IO…

Yves Parès
- 581
- 5
- 14
3
votes
1 answer
How do you save a file using Conduit?
How do you save a file using conduit's library? I looked through conduit's tutorial but can't seem to find anything, here is my use case:
main :: IO ()
main = do
xxs <- lines <$> (readFile filePath)
sourceList xxs =$ pipe $$ saveFile
pipe ::…

xiaolingxiao
- 4,793
- 5
- 41
- 88
3
votes
2 answers
Haskell Pipes -- Having a pipe consume what it yields (itself)
I'm trying to write a webscraper using Pipes and I've come to the part of following scraped links. I have a process function that downloads a url, finds links, and yields them.
process :: Pipe Item Item (StateT CState IO) ()
....
for (each…

user1055947
- 862
- 3
- 9
- 22
3
votes
0 answers
Using pipes-csv to parse Latin-1 encoded content?
I'd like to use pipes-csv to parse some large CSV files, but it turns out these CSV files are Latin-1 encoded and it also turns out that pipes-csv, and the cassava library it depends on, assume UTF-8. This ends up producing parsing errors that I…

frivat
- 31
- 2
3
votes
0 answers
Interleaving WAI streaming with safe-pipes
I'm using pipes and WAI to stream audio. The problem is that I need to lookahead some data in safe-pipe, then choose response headers based on extracted information, and then continue streaming that pipe as the response body. Here is what I have now…

aemxdp
- 1,348
- 1
- 14
- 34
3
votes
2 answers
Construct a pipes Proxy inside-out
Is it possible to make a function so that a Proxy from pipes can be constructed inside-out? By inside-out, I mean create a proxy from a function that connects the upstream and downstream connections. The most desirable (but impossible) signature…

Cirdec
- 24,019
- 2
- 50
- 100
3
votes
1 answer
Pipes equivalent code for simple functions
Let's say, I have the following types:
type LinkID = Int
data Link = Link {
lid :: LinkID,
llength :: Int
}
data Snap = Snap {
slid :: LinkID,
slength :: Int
}
Now, I want to write a pipes based function which does this:
getSnaps ::…

Sibi
- 47,472
- 16
- 95
- 163
3
votes
2 answers
Embed async within a Monad implementing MonadIO
I have some pipes-concurrency code that looks like this:
-- this won't compile but will give you the gist of what's happening
pipeline :: MonadIO m => Consumer a m ()
main = do
(output, input) <- spawn Unbounded
async $ do runEffect $…

aaronlevin
- 1,433
- 2
- 13
- 18