bytestring Questions

1

Solved

With the following code, I want to serialize a Data.Text value to a ByteString. Unfortunately my text is prepended with unnecessary NUL bytes and an EOT byte: GHCi, version 9.4.4: https://www.haske...
Oreopithecus asked 19/1 at 20:18

5

Solved

What's an idiomatic way of treating a bytestring nibblewise and pretty printing its hexadecimal (0-F) representation? putStrLn . show . B.unpack -- [1,126] Which, upon further work putStrLn . s...
Slipway asked 7/12, 2011 at 8:39

5

Solved

I want to split ByteString to words like so: import qualified Data.ByteString as BS main = do input <- BS.getLine let xs = BS.split ' ' input But it appears that GHC can't convert a chara...
Flail asked 16/5, 2012 at 17:15

1

Solved

I am learning Haskell but having some difficulty understanding how exactly lazy ByteStrings work. Hackage says that "Lazy ByteStrings use a lazy list of strict chunks which makes it suitable f...
Streetwalker asked 24/5, 2021 at 3:48

2

The core datatypes of Data.ByteString.Builder are newtype Builder = Builder (forall r. BuildStep r -> BuildStep r) type BuildStep a = BufferRange -> IO (BuildSignal a) data BuildSignal a =...
Domeniga asked 4/4, 2018 at 11:46

3

Solved

We'd like to serialize data in a specific binary format. We use Data.ByteStrings internally. So, the question is: How to convert the different data types we use to a ByteString. For String we have...
Conard asked 17/2, 2010 at 17:56

2

Solved

For String there is ++, which has type > :t (++) (++) :: [a] -> [a] -> [a] Evidently it doesn't work on ByteString because it isn't a list. I see the append function but is there an ope...
Kilogram asked 21/2, 2018 at 9:38

1

So happy making it this far, encountered a new hurdle: Got this code made to be encoded to JSON. However no matter when type I use as an instance, the compiler complains. Now I am obviously doing ...
Remonaremonetize asked 14/11, 2018 at 8:33

2

Solved

In an ongoing endeavour to efficiently fiddle with bits (e.g. see this SO question) the newest challenge is the efficient streaming and consumption of bits. As a first simple task I choose to find...
Fillender asked 30/4, 2018 at 13:13

1

Solved

I'm trying to return a ByteString from my Handler function in Yesod: getHomeR :: Handler ByteString getHomeR = return "foo" but I'm getting this error: /Users/maximiliantagher/Documents/Mercury...
Illness asked 15/12, 2017 at 18:39

1

Solved

I read that Char8 only supports ASCII characters and will be dangerous to use if you are using other Unicode characters {-# LANGUAGE OverloadedStrings #-} --import qualified Data.ByteString as B ...
Entozoic asked 23/11, 2017 at 2:19

1

Solved

I am trying to generate large random prime numbers (1024 bit-ish) so I need a way to generate large positive random numbers. I began with System.Random but want to move to Crypto.Random from the c...
Sentiment asked 1/11, 2017 at 7:20

5

Solved

I have a function that takes a lazy ByteString, that I wish to have return lists of strict ByteStrings (the laziness should be transferred to the list type of the output). import qualified Data.By...
Marniemaro asked 19/10, 2011 at 0:50

3

Solved

What is the best way to convert a String to a ByteString in Haskell? My gut reaction to the problem is import qualified Data.ByteString as B import Data.Char (ord) packStr = B.pack . map (fromIn...
Miskolc asked 12/7, 2010 at 20:35

0

Is there a cross-platform way to parse program arguments into a list of ByteString (instead of a list of String, as in System.Environment.getArgs)? I am aware of System.Posix.Env.ByteString.getArg...
Klaipeda asked 3/1, 2016 at 0:1

2

Solved

I am trying to write a very large amount of data to a file in constant memory. import qualified Data.ByteString.Lazy as B {- Creates and writes num grids of dimensions aa x aa -} writeGrids :: In...
Leeannaleeanne asked 21/7, 2015 at 13:51

1

The hackage documentation for ByteString contains this example: split :: Word8 -> ByteString -> [ByteString] split '\n' "a\nb\nd\ne" == ["a","b","d","e"] It's as if '\n' is converted...
Telluric asked 22/12, 2014 at 8:11

1

Solved

Seems like strict ByteString is structuraly same as Vector Word8. Why ByteString is not deprecated in favor of Vector? Are there performance examples when ByteString is faster than Vector Byte8?
Chaco asked 1/7, 2014 at 19:36

5

Solved

I'm a Haskell newbie, and having a bit of trouble figuring out how to pattern match a ByteString. The [Char] version of my function looks like: dropAB :: String -> String dropAB [] = [] dropAB ...
Beating asked 29/10, 2010 at 22:47

2

Solved

In Haskell, how can I replace an ASCII character sub-string in a ByteString? How can I use function replace in Data.ByteString.Search using character strings as arguments? Are there other ways to p...
Dragone asked 24/2, 2014 at 14:52

1

Solved

The Haskell parser/combinator Parsec supports input streams from Data.ByteString and Data.Text. Are there any plans to add more support for these types in future releases? The combinators (many, se...
Piliform asked 7/2, 2014 at 5:52

4

Solved

I am trying to find frequency of characters in file using Haskell. I want to be able to handle files ~500MB size. What I've tried till now It does the job but is a bit slow as it parses the file...
Hulbig asked 15/1, 2014 at 8:3

1

Solved

Running the following code: import Crypto.BCrypt import Data.ByteString.Lazy.Char8 main = do maybe_pwhash <- hashPasswordUsingPolicy slowerBcryptHashingPolicy (pack "hunter2") print $ maybe_...
Cordite asked 22/12, 2013 at 20:47

1

Solved

Is there a way to extract underlying direct pointer to memory off the ByteString object? My current approach is incorrect, compiler says. getPtr :: ByteString -> Ptr Word8 getPtr (PS ptr _ _) =...
Eugenides asked 24/11, 2013 at 20:46

1

Solved

Consider the following code: http://hpaste.org/90394 I am memory mapping a large 460mb file to a lazy ByteString. The length of the ByteString reports 471053056. When nxNodeFromID file 110000 is ...
Jermaine asked 25/6, 2013 at 7:56

© 2022 - 2024 — McMap. All rights reserved.