Skip to content

Fix takeAllTreesContent to only consume a single tag/tree.#98

Merged
k0ral merged 3 commits intosnoyberg:masterfrom
merijn:takealltrees
Feb 4, 2017
Merged

Fix takeAllTreesContent to only consume a single tag/tree.#98
k0ral merged 3 commits intosnoyberg:masterfrom
merijn:takealltrees

Conversation

@merijn
Copy link
Copy Markdown
Contributor

@merijn merijn commented Feb 3, 2017

The documentation of takeAllTreesContent implies it consumes only a single
tag/tree, however it's implementation currently consumes every single event
remaining in the stream.

Fixes #97.

The documentation of `takeAllTreesContent` implies it consumes only a single
tag/tree, however it's implementation currently consumes every single event
remaining in the stream.

Fixes snoyberg#97.
@k0ral
Copy link
Copy Markdown
Collaborator

k0ral commented Feb 3, 2017

The documentation is indeed misleading:

  • the analogy with ignoreAllTreesContent is currently incorrect, since the latter is consuming at most one tag;
  • the provided examples are however correct as they clearly show that multiple tags are consumed.

I'm completely in favor of this change, but as is it looks incorrect to me: the recursive calls to takeAllTreesContent that you didn't remove, must be called many times, otherwise you will only match a single subtag at each layer of the tree.

@merijn
Copy link
Copy Markdown
Contributor Author

merijn commented Feb 3, 2017

Yes, see my comments on the issue. This requires some form of many to deal with multiple tags inside a tag. I was going to update this, but figured it'd be nicer to do it using skipMany (or whatever we end up calling it) from the other PR

@merijn
Copy link
Copy Markdown
Contributor Author

merijn commented Feb 3, 2017

One of these days I will learn to not push until I'm done testing...

@merijn
Copy link
Copy Markdown
Contributor Author

merijn commented Feb 3, 2017

ok, this is roughly how takeAllTreesContent should work, unfortunately this doesn't typecheck because many_ inherits it's Consumer using type signature from manyIgnoreYield, for it to work these would have to be changed/generalised to allow emitting results (something I'm not sure is desirable? It might be for many_, but probably not for manyIgnoreYield).

I don't know if there's a way to work around this restriction (I'm not too familiar with Conduit). Alternatively, maybe we should implement the more general version and export manyIgnoreYield with the current restricted type and change many_ to be more permissive and work with this code.

I'll leave you (@k0ral) to think on that, 'cause it's now bedtime for me.

@k0ral k0ral merged commit 4f288c9 into snoyberg:master Feb 4, 2017
@k0ral
Copy link
Copy Markdown
Collaborator

k0ral commented Feb 4, 2017

Considering that all exported parsers are ConduitMs rather than Consumers, even though they don't yield anything, I'm assuming there was no intention to prevent users from yielding values within parsers (there's even a unit test that does exactly that), therefore it makes sense to have combinators work on ConduitM as well.
I've merged and fixed your changes, thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants