I have a huge Json file that I would like to avoid loading entirely to memory. Its structure is pretty simple: it consists of a large array with arbitrary elements inside. I'd simply like to transform the array by randomly dropping most of the elements, and simply outputting the transformed Json.
Haskell seems well suited to this problem with all the laziness, and I thought it would make a nice Haskell exercise (I'm not an expert, and I don't know much FP theory).
I've found pipes-aeson [1] which seems to be what I want, but after trying for a while, I have to admit I'm stuck. There are almost no examples, and while I can work with Pipes to downsample data, working with a Parser object seems more complicated. The option I've found (evalStateT) is strict and parses the whole thing, without letting me intervene.
Maybe Lenses would be the solution to my problem, but they're very abstract I don't get what they are nor how to use them.
Could someone more knowledgeable than I am provide a little guidance?
[1] https://hackage.haskell.org/package/pipes-aeson-0.4.1.3/docs/Pipes-Aeson.html#t:DecodingError