Questions tagged [lazy-io]

In Haskell, lazy-IO actions return their result before the IO is completely performed. For instance, getContents returns a lazy string which will cause the file to be actually read only when characters are accessed from the string. Since it is hard to predict when the IO will actually happen, lazy-IO is fragile and must be used with some care. Popular deterministic alternatives are conduit and pipes.

18 questions
0
votes
0 answers

Efficiently add trailing newline to JSON ByteString emitted by Aeson when writing to file

By default, Aeson encode or encodePretty do not append a trailing newline to the ByteString. I.e., when viewing the resulting file in vim I see the [noeol] indicator. What is a performant/idiomatic way to append a newline to the file? Here's an…
kostmo
  • 6,222
  • 4
  • 40
  • 51
0
votes
2 answers

How do I get lazy streaming into the foldl'?

How does one make their own streaming code? I was generating about 1,000,000,000 random pairs of war decks, and I wanted them to be lazy streamed into a foldl', but I got a space leak! Here is the relevant section of code: main = do games <-…
PyRulez
  • 10,513
  • 10
  • 42
  • 87
0
votes
2 answers

reading files with references to other files in haskell

I am trying to expand regular markdown with the ability to have references to other files, such that the content in the referenced files is rendered at the corresponding places in the "master" file. But the furthest I've come is to implement…
epsilonhalbe
  • 15,637
  • 5
  • 46
  • 74
1
2