{"action":"created","comment":{"url":"https://api.github.com/repos/mirage/irmin/pulls/comments/194998276","pull_request_review_id":128276324,"id":194998276,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NDk5ODI3Ng==","diff_hunk":"@@ -32,6 +32,139 @@ module Cstruct = struct\n   let of_string s = Ok (Cstruct.of_string s)\n end\n \n+type json = [\n+  | `Null\n+  | `Bool of bool\n+  | `String of string\n+  | `Float of float\n+  | `O of (string * json) list\n+  | `A of json list\n+]\n+\n+let json =\n+  let open Type in\n+  mu (fun ty ->\n+  variant \"json\" (fun null bool string float obj arr -> function\n+    | `Null -> null\n+    | `Bool b -> bool b\n+    | `String s -> string s\n+    | `Float f -> float f\n+    | `O o -> obj o\n+    | `A a -> arr a)\n+  |~ case0 \"null\" `Null\n+  |~ case1 \"bool\" bool (fun x -> `Bool x)\n+  |~ case1 \"string\" string (fun x -> `String x)\n+  |~ case1 \"float\" float (fun x -> `Float x)\n+  |~ case1 \"object\" (list (pair string ty)) (fun obj -> `O obj)\n+  |~ case1 \"array\" (list ty) (fun arr -> `A arr)\n+  |> sealv)\n+\n+module Json = struct\n+  type t = (string * json) list\n+\n+  let t = Type.(list (pair string json))\n+\n+  let merge_object a b =\n+    try\n+      List.fold_right (fun (k, v) acc ->\n+        match List.assoc_opt k b with\n+        | Some x when v <> x -> failwith \"Unable to merge JSON objects\"\n+        | Some _ -> acc\n+        | _ -> (k, v) :: acc\n+      ) a b\n+      |> Merge.ok\n+    with\n+      Failure msg -> Merge.conflict \"%s\" msg\n+\n+  let merge ~old t1 t2 =\n+    let open Merge.Infix in\n+    old () >>=* function\n+      | Some j ->\n+          if j = t1 then","path":"src/irmin/contents.ml","position":52,"original_position":52,"commit_id":"1053b3d97015f7e0d0338a3516d6cdf24d77d2bb","original_commit_id":"1053b3d97015f7e0d0338a3516d6cdf24d77d2bb","user":{"login":"samoht","id":103693,"node_id":"MDQ6VXNlcjEwMzY5Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/103693?v=4","gravatar_id":"","url":"https://api.github.com/users/samoht","html_url":"https://github.com/samoht","followers_url":"https://api.github.com/users/samoht/followers","following_url":"https://api.github.com/users/samoht/following{/other_user}","gists_url":"https://api.github.com/users/samoht/gists{/gist_id}","starred_url":"https://api.github.com/users/samoht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samoht/subscriptions","organizations_url":"https://api.github.com/users/samoht/orgs","repos_url":"https://api.github.com/users/samoht/repos","events_url":"https://api.github.com/users/samoht/events{/privacy}","received_events_url":"https://api.github.com/users/samoht/received_events","type":"User","site_admin":false},"body":"not sure if you want to use `=` here or a custom equality on JSON objects.","created_at":"2018-06-13T08:38:22Z","updated_at":"2018-06-13T08:50:23Z","html_url":"https://github.com/mirage/irmin/pull/516#discussion_r194998276","pull_request_url":"https://api.github.com/repos/mirage/irmin/pulls/516","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/mirage/irmin/pulls/comments/194998276"},"html":{"href":"https://github.com/mirage/irmin/pull/516#discussion_r194998276"},"pull_request":{"href":"https://api.github.com/repos/mirage/irmin/pulls/516"}}},"pull_request":{"url":"https://api.github.com/repos/mirage/irmin/pulls/516","id":194425383,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0NDI1Mzgz","html_url":"https://github.com/mirage/irmin/pull/516","diff_url":"https://github.com/mirage/irmin/pull/516.diff","patch_url":"https://github.com/mirage/irmin/pull/516.patch","issue_url":"https://api.github.com/repos/mirage/irmin/issues/516","number":516,"state":"open","locked":false,"title":"JSON contents","user":{"login":"zshipko","id":332534,"node_id":"MDQ6VXNlcjMzMjUzNA==","avatar_url":"https://avatars1.githubusercontent.com/u/332534?v=4","gravatar_id":"","url":"https://api.github.com/users/zshipko","html_url":"https://github.com/zshipko","followers_url":"https://api.github.com/users/zshipko/followers","following_url":"https://api.github.com/users/zshipko/following{/other_user}","gists_url":"https://api.github.com/users/zshipko/gists{/gist_id}","starred_url":"https://api.github.com/users/zshipko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zshipko/subscriptions","organizations_url":"https://api.github.com/users/zshipko/orgs","repos_url":"https://api.github.com/users/zshipko/repos","events_url":"https://api.github.com/users/zshipko/events{/privacy}","received_events_url":"https://api.github.com/users/zshipko/received_events","type":"User","site_admin":false},"body":"This is my current implementation of a JSON datatype -- it is roughly modeled after a document store, like CouchDB or MongoDB, so it restricts top-level values to objects only. \r\n\r\nI think it is a nice addition because even though the `String` type can already be used to store JSON contents, this allows for the JSON encoding to be validated when using the command line tool.\r\n\r\nI'm not totally sure if it's ready to be merged but wanted to at least open this up to discussion in order to get some feedback before I continue.\r\n\r\n\r\n","created_at":"2018-06-12T22:28:51Z","updated_at":"2018-06-13T08:50:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a2a99ba8aa0229f6b980f5ffc0559a8459b3da59","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mirage/irmin/pulls/516/commits","review_comments_url":"https://api.github.com/repos/mirage/irmin/pulls/516/comments","review_comment_url":"https://api.github.com/repos/mirage/irmin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mirage/irmin/issues/516/comments","statuses_url":"https://api.github.com/repos/mirage/irmin/statuses/1053b3d97015f7e0d0338a3516d6cdf24d77d2bb","head":{"label":"zshipko:json-datatype","ref":"json-datatype","sha":"1053b3d97015f7e0d0338a3516d6cdf24d77d2bb","user":{"login":"zshipko","id":332534,"node_id":"MDQ6VXNlcjMzMjUzNA==","avatar_url":"https://avatars1.githubusercontent.com/u/332534?v=4","gravatar_id":"","url":"https://api.github.com/users/zshipko","html_url":"https://github.com/zshipko","followers_url":"https://api.github.com/users/zshipko/followers","following_url":"https://api.github.com/users/zshipko/following{/other_user}","gists_url":"https://api.github.com/users/zshipko/gists{/gist_id}","starred_url":"https://api.github.com/users/zshipko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zshipko/subscriptions","organizations_url":"https://api.github.com/users/zshipko/orgs","repos_url":"https://api.github.com/users/zshipko/repos","events_url":"https://api.github.com/users/zshipko/events{/privacy}","received_events_url":"https://api.github.com/users/zshipko/received_events","type":"User","site_admin":false},"repo":{"id":125550574,"node_id":"MDEwOlJlcG9zaXRvcnkxMjU1NTA1NzQ=","name":"irmin","full_name":"zshipko/irmin","owner":{"login":"zshipko","id":332534,"node_id":"MDQ6VXNlcjMzMjUzNA==","avatar_url":"https://avatars1.githubusercontent.com/u/332534?v=4","gravatar_id":"","url":"https://api.github.com/users/zshipko","html_url":"https://github.com/zshipko","followers_url":"https://api.github.com/users/zshipko/followers","following_url":"https://api.github.com/users/zshipko/following{/other_user}","gists_url":"https://api.github.com/users/zshipko/gists{/gist_id}","starred_url":"https://api.github.com/users/zshipko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zshipko/subscriptions","organizations_url":"https://api.github.com/users/zshipko/orgs","repos_url":"https://api.github.com/users/zshipko/repos","events_url":"https://api.github.com/users/zshipko/events{/privacy}","received_events_url":"https://api.github.com/users/zshipko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zshipko/irmin","description":"Irmin is a distributed database that follows the same design principles as Git","fork":true,"url":"https://api.github.com/repos/zshipko/irmin","forks_url":"https://api.github.com/repos/zshipko/irmin/forks","keys_url":"https://api.github.com/repos/zshipko/irmin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zshipko/irmin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zshipko/irmin/teams","hooks_url":"https://api.github.com/repos/zshipko/irmin/hooks","issue_events_url":"https://api.github.com/repos/zshipko/irmin/issues/events{/number}","events_url":"https://api.github.com/repos/zshipko/irmin/events","assignees_url":"https://api.github.com/repos/zshipko/irmin/assignees{/user}","branches_url":"https://api.github.com/repos/zshipko/irmin/branches{/branch}","tags_url":"https://api.github.com/repos/zshipko/irmin/tags","blobs_url":"https://api.github.com/repos/zshipko/irmin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zshipko/irmin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zshipko/irmin/git/refs{/sha}","trees_url":"https://api.github.com/repos/zshipko/irmin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zshipko/irmin/statuses/{sha}","languages_url":"https://api.github.com/repos/zshipko/irmin/languages","stargazers_url":"https://api.github.com/repos/zshipko/irmin/stargazers","contributors_url":"https://api.github.com/repos/zshipko/irmin/contributors","subscribers_url":"https://api.github.com/repos/zshipko/irmin/subscribers","subscription_url":"https://api.github.com/repos/zshipko/irmin/subscription","commits_url":"https://api.github.com/repos/zshipko/irmin/commits{/sha}","git_commits_url":"https://api.github.com/repos/zshipko/irmin/git/commits{/sha}","comments_url":"https://api.github.com/repos/zshipko/irmin/comments{/number}","issue_comment_url":"https://api.github.com/repos/zshipko/irmin/issues/comments{/number}","contents_url":"https://api.github.com/repos/zshipko/irmin/contents/{+path}","compare_url":"https://api.github.com/repos/zshipko/irmin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zshipko/irmin/merges","archive_url":"https://api.github.com/repos/zshipko/irmin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zshipko/irmin/downloads","issues_url":"https://api.github.com/repos/zshipko/irmin/issues{/number}","pulls_url":"https://api.github.com/repos/zshipko/irmin/pulls{/number}","milestones_url":"https://api.github.com/repos/zshipko/irmin/milestones{/number}","notifications_url":"https://api.github.com/repos/zshipko/irmin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zshipko/irmin/labels{/name}","releases_url":"https://api.github.com/repos/zshipko/irmin/releases{/id}","deployments_url":"https://api.github.com/repos/zshipko/irmin/deployments","created_at":"2018-03-16T17:44:52Z","updated_at":"2018-06-08T19:54:13Z","pushed_at":"2018-06-12T22:01:54Z","git_url":"git://github.com/zshipko/irmin.git","ssh_url":"git@github.com:zshipko/irmin.git","clone_url":"https://github.com/zshipko/irmin.git","svn_url":"https://github.com/zshipko/irmin","homepage":"","size":8660,"stargazers_count":0,"watchers_count":0,"language":"OCaml","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"isc","name":"ISC License","spdx_id":"ISC","url":"https://api.github.com/licenses/isc","node_id":"MDc6TGljZW5zZTEw"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mirage:master","ref":"master","sha":"1d97a0b890f34a0faa2b0daaeda039bb37000eca","user":{"login":"mirage","id":131943,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMTk0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/131943?v=4","gravatar_id":"","url":"https://api.github.com/users/mirage","html_url":"https://github.com/mirage","followers_url":"https://api.github.com/users/mirage/followers","following_url":"https://api.github.com/users/mirage/following{/other_user}","gists_url":"https://api.github.com/users/mirage/gists{/gist_id}","starred_url":"https://api.github.com/users/mirage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirage/subscriptions","organizations_url":"https://api.github.com/users/mirage/orgs","repos_url":"https://api.github.com/users/mirage/repos","events_url":"https://api.github.com/users/mirage/events{/privacy}","received_events_url":"https://api.github.com/users/mirage/received_events","type":"Organization","site_admin":false},"repo":{"id":9595928,"node_id":"MDEwOlJlcG9zaXRvcnk5NTk1OTI4","name":"irmin","full_name":"mirage/irmin","owner":{"login":"mirage","id":131943,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMTk0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/131943?v=4","gravatar_id":"","url":"https://api.github.com/users/mirage","html_url":"https://github.com/mirage","followers_url":"https://api.github.com/users/mirage/followers","following_url":"https://api.github.com/users/mirage/following{/other_user}","gists_url":"https://api.github.com/users/mirage/gists{/gist_id}","starred_url":"https://api.github.com/users/mirage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mirage/subscriptions","organizations_url":"https://api.github.com/users/mirage/orgs","repos_url":"https://api.github.com/users/mirage/repos","events_url":"https://api.github.com/users/mirage/events{/privacy}","received_events_url":"https://api.github.com/users/mirage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mirage/irmin","description":"Irmin is a distributed database that follows the same design principles as Git","fork":false,"url":"https://api.github.com/repos/mirage/irmin","forks_url":"https://api.github.com/repos/mirage/irmin/forks","keys_url":"https://api.github.com/repos/mirage/irmin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mirage/irmin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mirage/irmin/teams","hooks_url":"https://api.github.com/repos/mirage/irmin/hooks","issue_events_url":"https://api.github.com/repos/mirage/irmin/issues/events{/number}","events_url":"https://api.github.com/repos/mirage/irmin/events","assignees_url":"https://api.github.com/repos/mirage/irmin/assignees{/user}","branches_url":"https://api.github.com/repos/mirage/irmin/branches{/branch}","tags_url":"https://api.github.com/repos/mirage/irmin/tags","blobs_url":"https://api.github.com/repos/mirage/irmin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mirage/irmin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mirage/irmin/git/refs{/sha}","trees_url":"https://api.github.com/repos/mirage/irmin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mirage/irmin/statuses/{sha}","languages_url":"https://api.github.com/repos/mirage/irmin/languages","stargazers_url":"https://api.github.com/repos/mirage/irmin/stargazers","contributors_url":"https://api.github.com/repos/mirage/irmin/contributors","subscribers_url":"https://api.github.com/repos/mirage/irmin/subscribers","subscription_url":"https://api.github.com/repos/mirage/irmin/subscription","commits_url":"https://api.github.com/repos/mirage/irmin/commits{/sha}","git_commits_url":"https://api.github.com/repos/mirage/irmin/git/commits{/sha}","comments_url":"https://api.github.com/repos/mirage/irmin/comments{/number}","issue_comment_url":"https://api.github.com/repos/mirage/irmin/issues/comments{/number}","contents_url":"https://api.github.com/repos/mirage/irmin/contents/{+path}","compare_url":"https://api.github.com/repos/mirage/irmin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mirage/irmin/merges","archive_url":"https://api.github.com/repos/mirage/irmin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mirage/irmin/downloads","issues_url":"https://api.github.com/repos/mirage/irmin/issues{/number}","pulls_url":"https://api.github.com/repos/mirage/irmin/pulls{/number}","milestones_url":"https://api.github.com/repos/mirage/irmin/milestones{/number}","notifications_url":"https://api.github.com/repos/mirage/irmin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mirage/irmin/labels{/name}","releases_url":"https://api.github.com/repos/mirage/irmin/releases{/id}","deployments_url":"https://api.github.com/repos/mirage/irmin/deployments","created_at":"2013-04-22T09:52:58Z","updated_at":"2018-06-13T08:32:01Z","pushed_at":"2018-06-13T08:31:59Z","git_url":"git://github.com/mirage/irmin.git","ssh_url":"git@github.com:mirage/irmin.git","clone_url":"https://github.com/mirage/irmin.git","svn_url":"https://github.com/mirage/irmin","homepage":"","size":8648,"stargazers_count":877,"watchers_count":877,"language":"OCaml","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":81,"mirror_url":null,"archived":false,"open_issues_count":47,"license":{"key":"isc","name":"ISC License","spdx_id":"ISC","url":"https://api.github.com/licenses/isc","node_id":"MDc6TGljZW5zZTEw"},"forks":81,"open_issues":47,"watchers":877,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mirage/irmin/pulls/516"},"html":{"href":"https://github.com/mirage/irmin/pull/516"},"issue":{"href":"https://api.github.com/repos/mirage/irmin/issues/516"},"comments":{"href":"https://api.github.com/repos/mirage/irmin/issues/516/comments"},"review_comments":{"href":"https://api.github.com/repos/mirage/irmin/pulls/516/comments"},"review_comment":{"href":"https://api.github.com/repos/mirage/irmin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mirage/irmin/pulls/516/commits"},"statuses":{"href":"https://api.github.com/repos/mirage/irmin/statuses/1053b3d97015f7e0d0338a3516d6cdf24d77d2bb"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"samoht"}}