Questions tagged [bytestring]

A time and space-efficient implementation of byte vectors for Haskell.

A time and space-efficient implementation of byte vectors using packed Word8 arrays, suitable for high performance use, both in terms of large data quantities, or high speed requirements. Byte vectors are encoded as strict Word8 arrays of bytes, and lazy lists of strict chunks, held in a ForeignPtr, and can be passed between C and Haskell with little effort. Documentation can be found at the bytestring hackage page.

206 questions
1
vote
1 answer

Lazy ByteString strange behaviour or bug?

When I'm testing my function intervalFinder in GHCI it seems to be working, but when I try to compile it, I have NO output: The function works on the input: *Main> intervalFinder $[B.pack"first",B.pack"second",B.empty,B.pack"third",B.emp ty] Loading…
MdxBhmt
  • 1,310
  • 8
  • 16
1
vote
2 answers

Where is Network.Socket.ByteString.Lazy's sendTo?

Both Network.Socket.ByteString and Network.Socket.ByteString.Lazy have a send function. Network.Socket.ByteString has a sendTo function, but Network.Socket.ByteString.Lazy doesn't. How can I use Network.Socket.ByteString's sendTo with a…
fadedbee
  • 42,671
  • 44
  • 178
  • 308
0
votes
1 answer

different utf8 encoding outputs between Python and Haskell

I'm trying to encode a has which is computed by hmac sha256 in Haskell and sometimes my function has different output when compared to it's Python counterpart. This is the python funciton: import requests import json import hmac import…
0
votes
0 answers

How to store Data.ByteString in database

I have a User model which has a salt and I'd like to save it in my data base. My model looks like this: {-# LANGUAGE EmptyDataDecls #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE…
Gian Laager
  • 474
  • 4
  • 14
0
votes
1 answer

Creating ByteString from String representation of chars in Haskell

I'm trying to create Char8 ByteString from String of already converted to bytes Chars. For example for String "65" I want ByteString on which unpack method will give me "A". Because 65 is equal to chr 65. It would be better if this method will able…
0
votes
1 answer

Print bytestrings on Spock Web Server

Visualize a bytestring body on a webserver run on Spock (localhost for instance) My goal : create website and view a bytestring (converted to text) Framework: Http Simple for performing request to restAPI Spock for my server I don't want…
user3680029
  • 179
  • 8
0
votes
1 answer

Haskell building simple JSON parser

Getting my feet wet with building stuff, and not being able to get Aeson to work properly I decided my new project is building a JSON parser. Very abstract since it is one way or another, so it wouldn't make sense to put all the code here. The…
Madderote
  • 1,107
  • 10
  • 19
0
votes
1 answer

Haskell - Reading entire Lazy ByteString

Context: I have a function defined in a library called toXlsx :: ByteString -> Xlsx (that ByteString is from Data.ByteString.Lazy) Now to do certain operations I've defined certain functions that operate on the same file, thus I would like to open,…
0
votes
0 answers

Building a bytestring containing the length/size?

This isn't the first time I run into this issue, but I haven't found a really nice solution for it so I thought I'd ask how others approach it. Many protocols include the size of the message (or a part of it) inside the message itself. For instance,…
Magnus
  • 4,644
  • 1
  • 33
  • 49
0
votes
0 answers

Receive ByteString by HTTP Request

I'm trying to download an JPG image with an HTTP request in a way that it can be decoded for further processing. It looks like a combination of the HTTP and the stb-image package should do the trick. The latter provides a decoding…
Anton Harald
  • 5,772
  • 4
  • 27
  • 61
0
votes
1 answer

Ptr Word8 to [Word8]

I'm using the library Network.Pcap, and it has the function toBS toBS :: (PktHdr, Ptr Word8) -> IO (PktHdr, B.ByteString) toBS (hdr, ptr) = do let len = hdrCaptureLength hdr s <- B.create (fromIntegral len) $ \p -> B.memcpy p ptr…
user1198582
0
votes
1 answer

Clumsy Looking Type Signature for ByteStrings in Haskell HTTP Response

I'm experimenting with the http-conduit library and have this simple example: #!/usr/bin/env stack {- stack --resolver lts-7.12 --install-ghc runghc --package http-conduit -} {-# LANGUAGE OverloadedStrings #-} import…
Mittenchops
  • 18,633
  • 33
  • 128
  • 246
0
votes
1 answer

Data.ByteString.Char8 does not export stripSuffix

I'm working on a stream of ByteStrings. I've imported ByteString via: import qualified Data.ByteString as B I can call every function from the ByteString library e.g.: reverseBS :: Monad m => Conduit B.ByteString m B.ByteString reverseBS = CL.map…
Thomas Vanhelden
  • 879
  • 8
  • 20
0
votes
0 answers

Extracting ByteString from IO context?

I have a function that makes a http request, I need to access the returned byte string. However, the monadic function I have doesn't seem to be able to return the ByteString separated from its IO. See below: executeRequest :: IO…
Babra Cunningham
  • 2,949
  • 1
  • 23
  • 50
0
votes
1 answer

ByteStrings and Strings

How to solve following problem: import Data.ByteString.Lazy as BS (readFile, ByteString, unpack, fromStrict) import Data.ByteString.Char8 as C8 (pack) import Data.ByteString.UTF8 (toString) import Data.Char …
Martin Fischer
  • 697
  • 1
  • 6
  • 27
1 2 3
13
14