Library to create/apply patches of clojure data

292 views
Skip to first unread message

Robin Heggelund Hansen

unread,
Nov 13, 2014, 3:31:39 AM11/13/14
to clo...@googlegroups.com
I'm in need of a library that is able to create a patch for some Clojure datastructure, and apply it at a later time. This has to work in both Clojure and Clojurescript.

The use case is that I'm autosaving a datastructure (through repeatedly doing ajax calls, could be done over websocket) that has 10-20kb of data, so I only want to send the diffs to the server. I'm currently using a combination of clojure.data/diff and some functions I've created myself to apply that diff. I don't particular like the api of clojure.data/diff as it's confusing (especially related to vectors) and, from my experience, doesn't always respect type information.

I'm currently in the process of creating my own library for this (will be open-source, you can follow the process at github.com/Skinney/differ), but before I invest alot of effort into this, I'm wondering if something like this already exists?

Thanks!

Ruslan Prokopchuk

unread,
Nov 14, 2014, 12:51:14 AM11/14/14
to clo...@googlegroups.com
May be this one will be helpful https://github.com/timothypratley/patchin

четверг, 13 ноября 2014 г., 11:31:39 UTC+3 пользователь Robin Heggelund Hansen написал:

Robin Heggelund Hansen

unread,
Nov 14, 2014, 2:35:24 AM11/14/14
to clo...@googlegroups.com
If you look at the issues list, you'll see that I tried it already ;)

Karsten Schmidt

unread,
Nov 15, 2014, 5:09:26 PM11/15/14
to clo...@googlegroups.com
Hi Robin, I just found a link to this library in the depths of the
Liberator docs:

https://github.com/daviddpark/clj-json-patch

Maybe that's more helpful... (haven't tried it myself, but had to think of you)
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Karsten Schmidt
http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk

Robin Heggelund Hansen

unread,
Nov 15, 2014, 5:13:31 PM11/15/14
to clo...@googlegroups.com
Thank you for the link. This doesn’t, from what I can tell, work on all Clojure datastructures, but a JSON-compatible subset.
> You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/WBY5f3SVYxs/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.

Karsten Schmidt

unread,
Nov 15, 2014, 5:31:39 PM11/15/14
to clo...@googlegroups.com
Yes, understood, but I thought it would give you at least a headstart...

Vladimir Bokov

unread,
Nov 16, 2014, 1:57:28 AM11/16/14
to clo...@googlegroups.com
Hi Robin,

I'm also highly interested in the subject as I'm trying to do essentially the same - reduce the client-server traffic using diffs over websocket.

I think a diff solution is only the basis, I think we should look at some VCS-like implementation to be able to merge some changes and to be able to calculate arbitrary diff not only between previous and current state, but comparing to some other state

What do you think?

четверг, 13 ноября 2014 г., 14:31:39 UTC+6 пользователь Robin Heggelund Hansen написал:

Robin Heggelund Hansen

unread,
Nov 16, 2014, 4:53:10 AM11/16/14
to clo...@googlegroups.com
Well, the diff would be arbitrary, and could be applied to any similar structure.


Reply all
Reply to author
Forward
0 new messages