Questions tagged [conduit]

conduit is a Haskell library for composable processing of streaming data.

conduit is a Haskell library for composable processing of streaming data. It was developed as an alternative to iteratee implementations such as enumerator and is now used by several popular packages, including WAI and http-conduit (formerly http-enumerator).

244 questions
62
votes
1 answer

One processing conduit, 2 IO sources of the same type

In my GHC Haskell application utilizing stm, network-conduit and conduit, I have a strand for each socket which is forked automatically using runTCPServer. Strands can communicate with other strands through the use of a broadcasting TChan. This…
kvanbere
  • 3,199
  • 2
  • 19
  • 43
49
votes
3 answers

What is pipes/conduit trying to solve

I have seen people recommending pipes/conduit library for various lazy IO related tasks. What problem do these libraries solve exactly? Also, when I try to use some hackage related libraries, it is highly likely there are three different versions.…
Sibi
  • 43,989
  • 14
  • 80
  • 146
34
votes
2 answers

What are the pros and cons of Enumerators vs. Conduits vs. Pipes?

I'd like to hear from someone with a deeper understanding than myself what the fundamental differences are between Enumerators, Conduits, and Pipes as well as the key benefits and drawbacks. Some discussion's already ongoing but it'd be nice to have…
Luke Hoersten
  • 6,885
  • 3
  • 18
  • 18
28
votes
1 answer

What's the conceptual difference between Machines and Conduits (or other similar libraries)?

I'd like to learn the concept, so that I'd be able to understand and use libraries such as machines. I tried to follow Rúnar Bjarnason's talk on machines, but there is too little information, basically just a bunch of data types. I can't even…
Petr
  • 60,177
  • 8
  • 136
  • 295
21
votes
2 answers

What is the preferred way to combine two sinks?

I've used zipSinks :: Monad m => Sink i m r -> Sink i m r' -> Sink i m (r, r') for this but it is considered deprecated.
tymmym
  • 488
  • 2
  • 9
19
votes
2 answers

What is the connection between Iteratees and FRP?

It seems to me that there is a strong connection between the two ideas. My guess is that FRP could be implemented in terms of Iteratees if there would be a way to express arbitrary graphs with Iteratees. But afaik they only support chain-like…
fho
  • 6,578
  • 19
  • 63
14
votes
2 answers

GHC rewrite rules with class constraints

I've added the following rewrite rule to conduit without issue: {-# RULES "ConduitM: lift x >>= f" forall m f. lift m >>= f = ConduitM (PipeM (liftM (unConduitM . f) m)) #-} I'm trying to add a similar rewrite rules for liftIO as well {-#…
Michael Snoyman
  • 30,497
  • 3
  • 43
  • 72
14
votes
2 answers

What's the benefit of conduit's leftovers?

I'm trying to understand the differences between conduit and pipes. Unlike pipes, conduit has the concept of leftovers. What are leftovers useful for? I'd like to see some examples where leftovers are essential. And since pipes don't have the…
Petr
  • 60,177
  • 8
  • 136
  • 295
12
votes
1 answer

What's the "easier way" that deprecates the need for Data.Conduit.Util's zip?

Getting started with conduit, and I noticed that in Data.Conduit.Util: Utility functions from older versions of conduit. These should be considered deprecated, as there are now easier ways to handle their use cases. This module is provided solely…
rampion
  • 82,104
  • 41
  • 185
  • 301
12
votes
4 answers

How do I implement `cat` in Haskell?

I am trying to write a simple cat program in Haskell. I would like to take multiple filenames as arguments, and write each file sequentially to STDOUT, but my program only prints one file and exits. What do I need to do to make my code print every…
Sam
  • 2,601
  • 2
  • 24
  • 27
11
votes
3 answers

Why does this cause a memory leak in the Haskell Conduit library?

I have a conduit pipeline processing a long file. I want to print a progress report for the user every 1000 records, so I've written this: -- | Every n records, perform the IO action. -- Used for progress reports to the user. progress :: (MonadIO m)…
Paul Johnson
  • 16,435
  • 3
  • 38
  • 54
11
votes
1 answer

Using persistent from within a Conduit

First up, a simplified version of the task I want to accomplish: I have several large files (amounting to 30GB) that I want to prune for duplicate entries. To this end, I establish a database of hashes of the data, and open the files one-by-one,…
Aleksandar Dimitrov
  • 8,790
  • 3
  • 39
  • 46
10
votes
1 answer

Is there any difference between "MonadIO m" and "MonadBaseControl IO m"?

Function runTCPClient from network-conduit has the following signature: runTCPClient :: (MonadIO m, MonadBaseControl IO m) => ClientSettings m -> Application m -> m () MonadIO m provides liftIO :: IO a -> m a and MonadBaseControl IO m…
Petr
  • 60,177
  • 8
  • 136
  • 295
10
votes
1 answer

Http-Conduit frequent connection failures

I am writing application which will download some files by HTTP. Up to some point I was using following code snippet to download page body: import network.HTTP simpleHTTP (getRequest "http://www.haskell.org/") >>= getResponseBody It was working…
Trismegistos
  • 3,745
  • 2
  • 20
  • 38
10
votes
1 answer

"InternalIOException getAddrInfo: does not exist (error 10093)" on Windows 8

Why is such simple code not working? import Network.HTTP.Conduit import qualified Data.ByteString.Lazy as L main :: IO () main = simpleHttp "http://www.dir.bg/" >>= L.putStr It results in the following error: TestConduit.exe: InternalIOException…
The_Ghost
  • 1,998
  • 13
  • 26
1
2 3
16 17