`pipes` is a group of libraries written in Haskell to provide safe, functional, and strict I/O.
Questions tagged [haskell-pipes]
139 questions
4
votes
1 answer
pipes and fork with Control.Concurrent.MonadIO
In the following code I am trying to combine 2 Producers into 1. All have the same type. They will be combined by each of the 2 input Producers being run in a separate thread and being consumed by a Consumer that puts the values into an unagi chan…

shmish111
- 3,697
- 5
- 30
- 52
4
votes
2 answers
How to pipe output from an IO action into a process in haskell
I want to create a process and write some text from my haskell program into the process's stdin periodically (from an IO action).
The following works correctly in GHCi but don't work correctly when built and run. In GHCi everything works perfectly…

Ajit Singh
- 193
- 6
4
votes
1 answer
Subsampling a huge json array with Haskell
I have a huge Json file that I would like to avoid loading entirely to memory. Its structure is pretty simple: it consists of a large array with arbitrary elements inside. I'd simply like to transform the array by randomly dropping most of the…

static_rtti
- 53,760
- 47
- 136
- 192
4
votes
1 answer
Running a monomorphic Consumer inside a Pipe
The question of how to run a Consumer inside a Pipe has already been asked, but the answer that was offered then requires the Consumer' polymorphic type synonym:
{-# LANGUAGE RankNTypes #-}
import Pipes
toPipe :: Monad m => Consumer' i m o -> Pipe…

Luis Casillas
- 29,802
- 7
- 49
- 102
4
votes
2 answers
Running a consumer inside a pipe
I need to compose a consumer and a pipe so that the output of the consumer would feed the input of the pipe.
I guess this could be solved with a combinator like this:
Consumer i m r -> (r -> Producer o m r') -> Pipe i o m r'
or this:
Consumer i m…

Nikita Volkov
- 42,792
- 11
- 94
- 169
4
votes
2 answers
Skipping first line in pipes-attoparsec
My types:
data Test = Test {
a :: Int,
b :: Int
} deriving (Show)
My parser:
testParser :: Parser Test
testParser = do
a <- decimal
tab
b <- decimal
return $ Test a b
tab = char '\t'
Now in order to skip the first line, I do something…

Sibi
- 47,472
- 16
- 95
- 163
4
votes
1 answer
How to find the end of Pipe
In the code below how can I
change stdoutCharConsumer so that it prints a newline after printing all the data from the input stream
implement mixin and mixin'
without going into Pipes.Internal? Is it possible? I need someting like the next…

amakarov
- 524
- 3
- 16
4
votes
5 answers
Join two consumers into a single consumer that returns multiple values?
I have been experimenting with the new pipes-http package and I had a thought. I have two parsers for a web page, one that returns line items and another a number from elsewhere in the page. When I grab the page, it'd be nice to string these…

David McHealy
- 2,471
- 18
- 34
4
votes
1 answer
How to pass arguments to foreign export functions into a Pipe?
I have a
foreign export stdcall tick :: Integer -> Float -> Float -> IO Int
On each invocation of this function, I wish to pass its arguments into a set of pipes from the haskell pipes library.
Between the invocations I don't want the pipes to…

Edwin Jose Palathinkal
- 635
- 5
- 12
4
votes
1 answer
Haskell: Splitting pipes (broadcast) without using spawn
This question is a bit codegolf and a lot newb.
I'm using the awesome pipes library in Haskell, and I'd like to split a pipe to send the same data along multiple channels (do a broadcast).
The Pipes.Concurrent tutorial suggests using spawn to create…

emchristiansen
- 3,550
- 3
- 26
- 40
4
votes
2 answers
How can I write a pipe that sends downstream a list of what it receives from upstream?
I'm having a hard time to write a pipe with this signature:
toOneBigList :: (Monad m, Proxy p) => () -> Pipe p a [a] m r
It should simply take all as from upstream and send them in a list downstream.
All my attempts look fundamentally broken.
Can…

Giacomo Tesio
- 7,144
- 3
- 31
- 48
4
votes
3 answers
Combining proxies with different EitherT in base monad
For example, having...
consumer :: Proxy p => () -> Consumer p a (EitherT String IO) ()
producer :: Proxy p => () -> Producer p a (EitherT ByteString IO) r
... how do I make this work?
session :: EitherT ByteString (EitherT String IO) ()
session =…

Danny Navarro
- 2,733
- 1
- 18
- 22
4
votes
2 answers
Writing a simple accumulator with pipes' WriterP
Using the pipes library, I want to write a program to read data from some source and accumulate it monoidally (say, with Sum). The easiest way to do this would be,
import Control.Proxy as
import Data.Monoid (Sum)
main = do
let source =…

bgamari
- 5,913
- 1
- 18
- 21
3
votes
1 answer
Stateful generators with Haskell pipes
Suppose I want to model, using Haskell pipes, a Python
Generator[int, None, None] which keeps some internal state. Should
I be using Producer int (State s) () or StateT s (Producer int m) (), where m is whatever type of effect I eventually want…

Eric Auld
- 1,156
- 2
- 14
- 23
3
votes
1 answer
Using request and response in with the Pipes library for bidirectional communication
This question is about the Haskell Pipes library
Background:
In a previous question, I asked how to form a cycle using pipes and the answer I got was "don't do that. Use request and response instead." While there is an excellent and clearly…

John F. Miller
- 26,961
- 10
- 71
- 121