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).

255 questions
0
votes
1 answer

SHA256 an uploaded file in Yesod - Using Conduit and Data.Digest.Pure.SHA

I am handling a file upload using yesod, and would like to save the uploaded file to a file on my server with the name being the SHA256 of the contents. I think the handler-level function will look like: fileMove fInfo (basePath <> generateSha…
cschneid
  • 460
  • 4
  • 10
0
votes
1 answer

Conduit and Attoparsec - extracting delimited text

Say I have a document with text delimited by Jade-style brackets, like {{foo}}. I've written an Attoparsec parser that seems to extract foo properly: findFoos :: Parser [T.Text] findFoos = many $ do manyTill anyChar (string "{{") manyTill letter…
Athan Clark
  • 3,886
  • 2
  • 21
  • 39
0
votes
1 answer

Haskell Conduit and masking async exceptions

I have the following line of code that uses aeson to serialize an IntMap and save the JSON to disk, all on a child thread: import Data.Aeson (encode, toJSON) import Data.Conduit (($$), (=$), yield) import qualified Data.ByteString.Lazy…
the-konapie
  • 601
  • 3
  • 10
0
votes
1 answer

Manually terminate inputs for Conduit Attoparsec

I am processing a syslog logfile, each line as an individual syslog entry, and parsing that entry using a Attoparsec parser. So I am using fileToBS :: IO Handle -> C.Source (ResourceT IO) BS.ByteString fileToBS handleMaker = source C.$=…
xrl
  • 2,155
  • 5
  • 26
  • 40
0
votes
1 answer

conduit stream to list of actions

I have: an infinite network stream as source (responseBody response) a parser: myParser = many1 parseOneObj of type Parser [MyObj] I would like to handle each object (for example printing it on screen). I am stuck here. I tried things…
yogsototh
  • 14,371
  • 1
  • 22
  • 21
0
votes
0 answers

How to model computations that depend on specific elements from a stream?

I am currently writing a program that analyzes files collected from multiple tar archives. I am using conduit, and the relevant code is here. Here is a sample computation : unixVersion :: Require T.Text BSL.ByteString UnixVersion unixVersion = …
bartavelle
  • 897
  • 8
  • 16
0
votes
0 answers

Sending a Stream request in Network.HTTP.Conduit

I am sending a request this way: import Network.HTTP.Conduit request <- parseUrl url res <- withManager $ httpLbs request That being said, I want to send a stream request and then iterate over it. I haven't found any mention of stream in the…
Incerteza
  • 32,326
  • 47
  • 154
  • 261
0
votes
2 answers

How can I conditionally apply a conduit?

I have a Conduit of type Conduit a m a and a function of type (a -> Maybe a). I want to run the function, and then if it returns Nothing, use the Conduit. That is, I want a function of type maybePipe :: Conduit a m b -> (a -> Maybe b) -> Conduit a m…
fread2281
  • 1,136
  • 1
  • 11
  • 31
0
votes
1 answer

Missing instance MonadIO for ConduitM?

According to the documentation there is a MonadIO instance for ConduitM if the underlying Monad has a MonadIO instance (MonadIO m => MonadIO (ConduitM i o m)). Why then does this: yield (1::Int) $$ await >>= (liftIO.print) :: IO () fail with…
Cubic
  • 14,902
  • 5
  • 47
  • 92
0
votes
1 answer

Word8 - ByteString encoding translations in Conduit

I'm trying to get a telnet client working as a side project, and I saw this gist as a basic example. When I compile and run it in ghci, however, you see that the encodings get garbled. Here is a reference of the characters: ���� ��#��' My guess is…
Athan Clark
  • 3,886
  • 2
  • 21
  • 39
0
votes
0 answers

Dynamic source with Conduit

I have a list that is constantly growing in parallel thread, for example inside IORef [a] or MVar [a]. I want to sink it also in parallel until the thread exits. How should I implement this? It may look something like this: main = do list <-…
swish
  • 367
  • 4
  • 18
0
votes
1 answer

How to detect the end of input in conduit?

I'm trying to use network-conduit as a backend for (patched) HaskellNet's IMAP. One of the required operations is to detect if the stream is open. Currently I'm using isOpen :: (Monad m) => ConduitM i o m Bool isOpen = await >>= maybe (return False)…
Petr
  • 62,528
  • 13
  • 153
  • 317
0
votes
1 answer

using console.log with conduit

I'm trying to debug a script written in javascript that runs on a conduit toolbar. for now i'm using simply window.alert("function x is working"); but this is very disturbing in case of many alerts as the script grows bigger. i would prefer to…
user1555863
  • 2,567
  • 6
  • 35
  • 50
0
votes
1 answer

How to collect output from pipes to file in Haskell

I have a producer pipe and I have used the print pipe. I would like to write the output to a file. If I use Control.Data.sinkFile, like test2file = runPipe $ CB.sinkFile "testOutput" <+< traverseTree fn3 I get a type error: Couldn't match…
user855443
  • 2,596
  • 3
  • 25
  • 37
-1
votes
1 answer

In haskell Conduit, how do I zip a Source that yields lists with one that doesn't

I'm using sourceFile which yields ByteString and another source that yields Word8. My Word8 source is infinite. I need a way to convert my Word8 source to a [Word8] source where the lists are the same length as the ByteString from the first source.
1 2 3
16
17