Questions tagged [haskell-pipes]

`pipes` is a group of libraries written in Haskell to provide safe, functional, and strict I/O.

139 questions
1
vote
2 answers

Understanding error in haskell

I (New to Haskell) am trying to perform unpack operation on ByteString that I receive from webpage. Basically I want to search few words from webpage so I am trying to tokenize stream, then search word from words. Prelude Network.HTTP.Conduit LB>…
Manvi
  • 1,136
  • 2
  • 18
  • 41
1
vote
2 answers

Haskell Pipes and testing with HSpec

I have written a program for a project that uses Pipes, which I love! I'm struggling to unit test my code however. I have a series of functions of type Pipe In Out IO () (for example) that I wish to test with HSpec. How can I go about this? For…
Alex
  • 8,093
  • 6
  • 49
  • 79
1
vote
1 answer

Decoding JSON stream where some values are needed before others

Let us say we have a JSON object like this (with base64 encoded bytestring): TaggedImage = TaggedImage { id :: Text, image :: ByteString } Now, we want to receive image from a source, and store it in a location using the information in id tag. So,…
Sal
  • 4,312
  • 1
  • 17
  • 26
1
vote
1 answer

Error handling in pipes

Backstory I have a number of data files, each of them containing a list of data records (one per line). Similar to CSV but sufficiently different that I'd prefer to write my own parser rather than using a CSV library. For the purpose of this…
Lemming
  • 4,085
  • 3
  • 23
  • 36
1
vote
1 answer

Catching exceptions in monad transformers

I'm using haskell-pipes to recursively traverse a directory and print the files. How do I handle exceptions from the Producer, which is a monad transformer? bracket and handle do not work in this case. import Control.Exception (handle,…
Jan Synáček
  • 355
  • 2
  • 9
1
vote
2 answers

Haskell Pipes: How do I sort the output of a producer?

I have the following piece of code: import Control.Monad (unless) import Pipes import qualified Pipes.Prelude as P import System.FilePath.Posix (()) import System.Posix.Directory (DirStream, openDirStream, readDirStream) produceFiles ::…
Jan Synáček
  • 355
  • 2
  • 9
1
vote
1 answer

Pipe that maintains state

I'm trying to calculate rolling hash values (buzzhash) for a big file using pipes. Currently I have this. But don't know how to write a pipe that maintains a state. import qualified Data.ByteString.Lazy as L import Data.Word import…
Dulguun Otgon
  • 1,925
  • 1
  • 19
  • 38
1
vote
1 answer

Haskell-pipes: how to use drawAll to test a producer with a MonadSafe constraint?

I have a producer which, given a path, traverses the filesystem yielding Haskell files' paths. It's built on top of pipes-files: import Pipes import Pipes.Files import Pipes.Safe import qualified Pipes.Prelude as P import Data.Monoid ((<>)) import…
rubik
  • 8,814
  • 9
  • 58
  • 88
1
vote
0 answers

Using Pipes.Safe with IO actions

I'm using Pipes.Files, which in turn relies upon Pipes.Safe. I have a pipeline like this: import Pipes import Pipes.Files import Pipes.Safe import qualified Pipes.Prelude as P allFiles :: (MonadIO m, MonadSafe m) => FilePath -> Producer FilePath m…
rubik
  • 8,814
  • 9
  • 58
  • 88
1
vote
2 answers

Forking the streaming flow in haskell-pipes

I'm having trouble directing flow though a pipeline with haskell-pipes. Basically, I analyze a bunch of files and then I have to either print results to the terminal in a human-friendly way encode results to JSON The chosen path depends upon a…
rubik
  • 8,814
  • 9
  • 58
  • 88
1
vote
1 answer

Pipes get Network.Socket.ByteString.recv: failed (Unknown error)

Maybe a silly way to do things, but here it goes. I wanted to split the HTTP request send/receive from processing the response. import Pipes import qualified Pipes.HTTP as HTTP import Pipes.Core import qualified Pipes.ByteString as PB import…
Sassa NF
  • 5,306
  • 15
  • 22
1
vote
0 answers

Could GHC be enhanced to print type aliases in error messages?

I'm wondering if this would be a reasonable feature request (even better if it already exists and I don't know how to access it). An example of why this is desirable is the pipes library. Pipes defines a type: data Proxy a' a b' b m r with a ton of…
Michael Fox
  • 3,632
  • 1
  • 17
  • 27
1
vote
1 answer

replacing an element in a list of lists -- haskell

I have this code : type Matrice = [[String]] matr =[[" - "," 0 "," - "],[" - "," - "," - "],[" - "," - "," - "]] changeValue :: Matrice ->Int->Int->Matrice changeValue mat x y = [ if ((mat !! x) !! y) /= " - " then mat …
Sami Li
  • 181
  • 1
  • 1
  • 9
1
vote
1 answer

Sleeping with pipes in Haste and Haskell

I'm working on a Haskell program that makes heavy use of the Pipes library. I'm porting part of the library to Haste. The one place where I've hit a stumbling block is in the odd way that javascript handles sleeping. What I wanted to write was a…
rprospero
  • 913
  • 11
  • 26
1
vote
1 answer

pipes for each evaluates before sending downstream?

going through the pipes tutorial led to toying with some examples: import Pipes import qualified Pipes.Prelude as P f1 :: Show a => Int -> [a] -> IO () f1 n xs = runEffect $ (for (each xs) (lift . putStrLn . show)) >-> P.take n …
sreekar
  • 57
  • 2