`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
Using pipes-parse to preserve leftovers with a map
I'm trying to understand how pipes-parse 3.0 works for cases besides span and splitAt, and can't quite figure out how to get things working. The basic idea is that I have an isomorphism, and I'd like to map all input values to convert from type A to…

Michael Snoyman
- 31,100
- 3
- 48
- 77
3
votes
1 answer
Connecting Producer and Pipe to extract the result
Having a producer of type Producer ByteString IO () and a pipe of type Pipe ByteString a IO () how do I compose an effect, which will result in IO a when run?
Here's my best attempt:
{-# LANGUAGE ScopedTypeVariables #-}
import Pipes
import…

Nikita Volkov
- 42,792
- 11
- 94
- 169
3
votes
1 answer
Pipe with dynamic request/response type?
This seems like a reasonable thing to want, but I'm having type troubles. I'd like to have a Client that can send a list of options to a Server, which will choose one and return the chosen element. So something like this:
module Toy where
import…

ajp
- 1,723
- 14
- 22
3
votes
2 answers
Converting StateT IO monad to use Control.Proxy - which is Server and which is Client?
I am implementing a game engine. Most of my code currently resides in a StateT Game IO () monad. I use IO to get user input, and in fact all IO channels through one function,
getChoice :: Show a => [ a ] -> IO a
which prompts the user with all…

ajp
- 1,723
- 14
- 22
2
votes
1 answer
Listing all the files under a directory recursively, using Pipes
I finished reading the Pipes tutorial, and I wanted to write a function to list all the files in a directory, recursively. I tried with the following code:
enumFiles :: FilePath -> Producer' FilePath (PS.SafeT IO) ()
enumFiles path =
PS.bracket…

Damian Nadales
- 4,907
- 1
- 21
- 34
2
votes
0 answers
Streaming-based pipe with common state
I'm Haskell beginner and newbie in Streaming library (https://hackage.haskell.org/package/streaming) as fastest and (I'm hope) simplest stream library. I'm trying to make next common and popular "pattern": processing of stream items with common…

RandomB
- 3,367
- 19
- 30
2
votes
1 answer
Why doesn't print force entire lazy IO value?
I'm using http-client tutorial to get response body using TLS connection. Since I can observe that print is called by withResponse, why doesn't print force entire response to the output in the following fragment?
withResponse request manager $…

sevo
- 4,559
- 1
- 15
- 31
2
votes
1 answer
Connecting Pipes with Consumers and Producers that return different values
I am writing a streaming function with the pipes ecosystem, and pipes-concurrency in particular, which is based on the operational library to allow me to quickly make little program snippets which I yield commands to a server over the network or to…

David McHealy
- 2,471
- 18
- 34
2
votes
1 answer
Understanding memory usage of this Haskell program
I should preface this with saying I'm very much a beginner with Haskell and the pipes library, and I would like to understand what is causing the high memory usage of this program in the test function.
Specifically in the fold that produces r1 value…

ppb
- 905
- 6
- 9
2
votes
1 answer
How do you make the output of a `readfile` function into source for conduit?
I am opening some .txt file via:
main :: IO ()
main = do
xxs <- TIO.readFile pathToFile
return ()
The .txt file is of form
str_1 \n str_2 \n ... str_m
And I would like to make xxs into a source so that it might look like:
sourceList [str_1,…

xiaolingxiao
- 4,793
- 5
- 41
- 88
2
votes
3 answers
Streaming bytes to network websocket
I have a code that uses a file handle to simulate sink for the streaming Bytestring from a source (AWS S3). If we want to use Network.Websocket as the sink, would it suffice to swap LBS.writeFile in the code below with sendBinaryData (with handle to…

Sal
- 4,312
- 1
- 17
- 26
2
votes
2 answers
haskell pipes - how to repeatedly perform a takeWhile operation on a bytestring pipe?
What I'm trying to do is use takeWhile to split a bytestring by some character.
import qualified Data.ByteString.Internal as BS (c2w, w2c)
import Pipes
import Pipes.ByteString as PB
import Pipes.GZip
import Pipes.Prelude as PP
import…

daj
- 6,962
- 9
- 45
- 79
2
votes
1 answer
Pipes.Concurrent: Sent signal is delivered one click later than expected
I'm using Pipes.Concurrent to write a short GUI program with GTK. It's a minesweeper-esque game, so I'm constructing a grid of buttons.
I construct and connect my buttons with:
b <- buttonNewWithLabel (show $ adjacencies board ! i)
on b…

the spectre
- 350
- 4
- 11
2
votes
0 answers
Nest a previously-flattened stream with Haskell Pipes
Background
I have a long stream of large files whose contents I would like to stream in constant memory.
I'm using the Haskell Pipes library to model this stream with the following nested type:
Producer (FilePath, Producer ByteString IO ()) IO…

jsk
- 285
- 1
- 7
2
votes
3 answers
How to replace double tabs with single tabs using pipes?
I need to replace all consecutive tabs in a bytestring with single tabs, like so:
"___\t___\t\t___\t\t\t___"
becomes
"___\t___\t___\t___"
I have no idea how to do it.
After half an hour of figuring stuff out I managed to replace the first…

Emily
- 2,577
- 18
- 38