It's a performance issue that causes quadratic time complexity if you do
something similar to this:
-- This is O(n^2)
replicateM_ n $ do
a <- zoom something parser
f a
If you're not doing that, then this doesn't affect you. If you are
doing this, then there are still solution to get back linear time
complexity.
On 6/9/14, 10:34 AM, Kai Wang wrote:
I vaguely remember there's some bug about "zoom" mentioned somewhere
on the list. was that fixed?
On Tuesday, May 20, 2014 7:43:44 PM UTC-7, Gabriel Gonzalez wrote:
I noticed you already came up with one solution judging by your
recent Stack Overflow question, but I wanted to mention another
solution: you can transform any `Parser` using `zoom` and a lens.
In this case you can write:
zoom decoded (foldAll step begin done)
On 05/17/2014 04:28 AM, Reuben Thomas wrote:
I'm trying to learn how to parse files with Pipes, using
Pipes.Aeson and Pipes.Parse. I'm a bit bewildered by the library
- it seems quite complex, and I couldn't find too many examples
of how it should be used.
For example:
I have a file containing several JSON objects all of the same
type. I'd like to read them into my program one-at-a-time and
reduce them down to some value.
From the documentation it looks like I should be using foldAll to
do this. foldAll returns a Parser.
However, the decode function in Pipes.Aeson has the type decode
:: (Monad m, FromJSON a) => Parser ByteString m (Either
DecodingError a) so it also returns a Parser.
I've written my own function that extracts a field from a parsed
JSON object, which has type :: Parser ByteString IO (Either
DecodingError Double), and a second function of type :: Parser
Double IO Double (and body foldAll max 0 id).
Is it possible to compose these into a single parser of type ::
Parser ByteString IO (Either DecodingError Double)? The intention
being that I extract the field from all the objects in the file,
then find the maximum.
Eventually I want to be able to run evalStateT on a Parser and a
Producer, but I'm having difficulties creating the Parser.
I'm sure this either has a really simple solution or I'm
approaching it in the wrong way. While I'm here - are there any
good resources or projects I can read through that have used the
Pipes.Parse (and maybe Pipes.Aeson) library? It'd be helpful to
see what idiomatic usage of the libraries looks like.
--
You received this message because you are subscribed to the
Google Groups "Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected] <javascript:>.
To post to this group, send email to [email protected]
<javascript:>.
--
You received this message because you are subscribed to the Google
Groups "Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
--
You received this message because you are subscribed to the Google Groups "Haskell
Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].