Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Use a finally tagless representation of a JSON AST #157

Closed
wants to merge 12 commits into
from

Conversation

Projects
None yet
2 participants
Collaborator

basvandijk commented Oct 26, 2013

This pull request is not meant to be merged yet! Its purpose is to let you know that I'm experimenting with this approach.

Note that this pull request is based on my scientific branch.

The code is not yet tested and benchmarked!

The experiment here is to see if a finally tagless representation of a JSON AST can be encoded more efficiently than the current tagfull representation using Value.

I only expect to see a performance boost when GHC is able to SPECIALIZE the dictionaries away.

The next step is to write some benchmarks.

Owner

bos commented Nov 19, 2013

This is interesting. I'd love to see how the performance works out with it. I'm a bit dubious that we can get the compiler to be smart enough.

Owner

bos commented Nov 19, 2013

By the way, I'd like to keep 0.7 open until we can decide whether this is worth doing or not. If it wins, it would be a big change, and a bigger deal.

Collaborator

basvandijk commented Nov 19, 2013

The last benchmark I ran for this had disappointing results. Encoding wasn't significantly faster than before. So I expect that the compiler isn't smart enough to remove all dictionaries.

Encoding objects was much faster though (twice as fast IIRC). However, this is very likely caused by avoiding going via a HashMap.

I'm not sure how to get GHC to fuse the dictionaries away. I'll give it one more try next Thursday. Then we have a mini hackathon at Erudify with Johan Tibell, Gregory Collins, Simon Meier and some other Haskellers. I'll make sure to also post some benchmark results then.

Owner

bos commented Nov 19, 2013

I'm a little surprised. That said, I've found it best to prototype stuff like this in a standalone way, because trying to make a core design change in the heart of a complex package makes it very difficult to understand the consequences of almost any change.

Collaborator

basvandijk commented Jan 5, 2014

Just a heads up that I'm working on a new idea in my json-builder branch. Benchmarks will follow later...

Owner

bos commented Jan 9, 2014

@basvandijk, that has a lot of overlap with the code that just went out with 0.7.0.0. Might want to look at @meiersi's commits.

Collaborator

basvandijk commented Jan 10, 2014

I've to catch a flight to Amsterdam which is a good chance to try to merge the latest master into my json-builder branch...

Owner

bos commented Jul 2, 2014

I'm going to close this for now. Please feel welcome to reopen if you get the time to make any further progress.

@bos bos closed this Jul 2, 2014

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