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
0
votes
2 answers

Console Output of bytestrings - deletes first character of next line

Answering haskell-convert-unicode-sequence-to-utf-8 I came upon some strange behaviour of ByteString.putStrLn {-# LANGUAGE OverloadedStrings #-} module Main where import Data.Text (Text) import Data.ByteString…
epsilonhalbe
  • 15,637
  • 5
  • 46
  • 74
0
votes
1 answer

How to approach writing of custom decoding function from `ByteString` to `Text`

Suppose I wish to write something like this: -- | Decode a 'ByteString' containing Code Page 437 encoded text. decodeCP437 :: ByteString -> Text decodeCP437 = undefined (I know about encoding package, but its dependency list is ridiculous price to…
Mark Karpov
  • 7,499
  • 2
  • 27
  • 62
0
votes
1 answer

Is my ToJSON Base64 instance sane? What would FromJSON instance look like?

I'm trying to encode a Base64 to JSON. I came across this dialogue. I noticed snoyberg has already included the Base64 newtype in the FP Complete codebase, so I thought I would give that a try. import qualified Data.ByteString as B import…
user1198582
0
votes
1 answer

Why does the Snap example use Bytestring?

I'm following the Snap example project, but when I copied the example code, Stack gave me errors complaining about the use of writeBS and how it expects a ByteString but is given a [Char]. So I imported a ByteString library and tried to convert all…
jeshaitan
  • 301
  • 1
  • 4
  • 16
0
votes
1 answer

Haskell: Changing an element at a given index in a ByteString

I'm trying to change a character at indices x and y in a matrix made of ByteStrings to a different character. Initially, I used [[Char]] to represent the matrix, so I was able to use .~ from Control.Lens.Setter to change the value, but this doesn't…
the spectre
  • 350
  • 4
  • 11
0
votes
1 answer

Haskell inbuilt libraries, where does it go?

In my /home/sk/.ghc/x86_64-linux-7.8.4/package.conf.d folder, there is an entry for bytestring package as, bytestring-0.10.6.0-7682cf7d45ee92d104399a67f3bce6ba.conf In my /opt/ghc/7.8.4/lib/ghc-7.8.4/package.conf.d folder, there is an entry for…
user2879704
0
votes
1 answer

Haskell ByteString type error

It is the first time I use ByteStrings and the first time I ever see a pcap file. I am basically trying to efficiently read the pcap file with ByteStrings and print its content on screen. I am using the Network.Pcap library to read the file. The…
mastro
  • 619
  • 1
  • 8
  • 17
0
votes
2 answers

Haskell optimization of a function looking for a bytestring terminator

Profiling of some code showed that about 65% of the time I was inside the following code. What it does is use the Data.Binary.Get monad to walk through a bytestring looking for the terminator. If it detects 0xff, it checks if the next byte is 0x00.…
me2
  • 3,069
  • 2
  • 26
  • 33
0
votes
1 answer

Haskell ByteString readInt return type issue

I am currently trying to understand how to handle the return type of `Maybe (Int, ByteString)' with the function Data.ByteString.Char8.readInt, I have removed the Maybe by type checking but do not understand how to further deal with the type I now…
user1156995
0
votes
1 answer

How faster Int comparison is than ByteString comparison in Haskell?

I'm implementing patterns mining algorithm, and usually input data are file with the following format item1 item2 item3 item0 item3 item10 .... item30 item40 item30 where usually itemx is a String. To be efficient, I used to read the file with…
Fopa Léon Constantin
  • 11,863
  • 8
  • 48
  • 82
0
votes
3 answers

Switching to ByteStrings

EDIT: I followed Yuras and Dave4420's advices (Thanks). I still have some errors. Updated the question. Finally I will use meiersi's version (Thanks) but I still want to find my errors... I have a simple script that goes like this: import…
sarfraz
  • 3
  • 2
1 2 3
13
14