{"action":"created","comment":{"url":"https://api.github.com/repos/tweag/rules_haskell/pulls/comments/187696173","pull_request_review_id":119517920,"id":187696173,"diff_hunk":"@@ -0,0 +1,344 @@\n+\"\"\"Support for protocol buffers\"\"\"\n+\n+load(\":providers.bzl\",\n+  \"HaskellBuildInfo\",\n+  \"HaskellLibraryInfo\",\n+  \"HaskellProtobufInfo\",\n+)\n+load(\"@bazel_skylib//:lib.bzl\", \"dicts\", \"paths\")\n+load(\":tools.bzl\", \"protobuf_tools\")\n+load(\":path_utils.bzl\", \"target_unique_name\")\n+load(\":haskell-impl.bzl\",\n+  _haskell_library_impl = \"haskell_library_impl\",\n+  _haskell_common_attrs = \"haskell_common_attrs\",\n+)\n+\n+def _capitalize_first_letter(c):\n+  \"\"\"Capitalize the first letter of the input. Unlike the built-in\n+  `capitalize()` method, doesn't lower-case the other characters. This helps\n+  mimic the behavior of `proto-lens-protoc`, which turns `Foo/Bar/BAZ.proto`\n+  into `Foo/Bar/BAZ.hs` (rather than `Foo/Bar/Baz.hs`).\n+\n+  Args:\n+    c: A non-empty string word.\n+\n+  Returns:\n+    The input with the first letter upper-cased.\n+  \"\"\"\n+  return c[0].capitalize() + c[1:]\n+\n+def _camel_case(comp):\n+  \"\"\"Camel-case the input string, preserving any existing capital letters.\n+  \"\"\"\n+  # Split on both \"-\" and \"_\", matching the behavior of proto-lens-protoc.\n+  return \"\".join([_capitalize_first_letter(c2)\n+                  for c1 in comp.split(\"_\") for c2 in c1.split(\"-\")])\n+\n+def _proto_lens_output_file(path):\n+  \"\"\"The output file from `proto-lens-protoc` when run on the given `path`.\n+  \"\"\"\n+\n+  path = path[:-len(\".proto\")]\n+  result = \"/\".join([_camel_case(p) for p in path.split(\"/\")]) + \".hs\"\n+\n+  return \"Proto/\" + result\n+\n+def _haskell_proto_aspect_impl(target, ctx):\n+\n+  args = ctx.actions.args()\n+\n+  src_prefix = paths.join(\n+    ctx.label.workspace_root,\n+    ctx.label.package,\n+  )\n+\n+  args.add([\"--plugin=protoc-gen-haskell=\" +\n+            protobuf_tools(ctx).plugin.path,\n+  ])\n+\n+  hs_files = []\n+  inputs = []\n+\n+  args.add([\"-I{0}={1}\".format(s.short_path, s.path)\n+            for s in target.proto.transitive_sources])\n+\n+  inputs.extend(target.proto.transitive_sources.to_list())\n+\n+  for src in target.proto.direct_sources:\n+\n+    inputs.append(src)\n+\n+    # As with the native rules, require the .proto file to be in the same\n+    # Bazel package as the proto_library rule. This allows us to put the\n+    # output .hs file next to the input .proto file. Unfortunately Skylark\n+    # doesn't let us check the package of the file directly, so instead we\n+    # just look at its short_path and rely on the proto_library rule itself\n+    # to check for consistency. We use the file's short_path rather than its\n+    # dirname/basename in case it's in a subdirectory; for example, if the\n+    # proto_library rule is in \"foo/BUILD\" but the .proto file is\n+    # \"foo/bar/baz.proto\".\n+\n+    if not src.short_path.startswith(src_prefix):\n+      fail(\"Mismatch between rule context \" + str(ctx.label.package)\n+           + \" and source file \" + src.short_path)\n+    if src.basename[-6:] != \".proto\":\n+      fail(\"bad extension for proto file \" + src)\n+\n+    relative_path = src.short_path\n+\n+    args.add([relative_path])\n+\n+    hs_files.append(ctx.actions.declare_file(\n+      _proto_lens_output_file(relative_path),\n+    ))\n+\n+  args.add([\n+    \"--haskell_out=no-reexports:\" + paths.join(\n+      hs_files[0].root.path,\n+      src_prefix,\n+    ),\n+  ])\n+\n+  ctx.actions.run(\n+    inputs = depset([\n+      protobuf_tools(ctx).protoc,\n+      protobuf_tools(ctx).plugin,\n+    ] + inputs),\n+    outputs = hs_files,\n+    executable = protobuf_tools(ctx).protoc,\n+    arguments = [args],\n+  )\n+\n+  patched_attrs = dict(\n+    {\n+      \"compiler_flags\": [],\n+      \"src_strip_prefix\": \"\",\n+      \"prebuilt_dependencies\": [],\n+      \"repl_interpreted\": True,\n+      \"repl_ghci_args\": [],\n+      \"version\": \"1.0.0\",\n+      \"_ghc_defs_cleanup\": ctx.attr._ghc_defs_cleanup,\n+      \"_ghci_script\": ctx.attr._ghci_script,\n+      \"_ghci_repl_wrapper\": ctx.attr._ghci_repl_wrapper,\n+      \"hidden_modules\": [],\n+    },\n+    name = \"proto-autogen-\" + ctx.rule.attr.name,","path":"haskell/protobuf.bzl","position":125,"original_position":125,"commit_id":"61a18597f30f00734674028aeeca11d43eabcced","original_commit_id":"61a18597f30f00734674028aeeca11d43eabcced","user":{"login":"judah","id":49143,"avatar_url":"https://avatars3.githubusercontent.com/u/49143?v=4","gravatar_id":"","url":"https://api.github.com/users/judah","html_url":"https://github.com/judah","followers_url":"https://api.github.com/users/judah/followers","following_url":"https://api.github.com/users/judah/following{/other_user}","gists_url":"https://api.github.com/users/judah/gists{/gist_id}","starred_url":"https://api.github.com/users/judah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/judah/subscriptions","organizations_url":"https://api.github.com/users/judah/orgs","repos_url":"https://api.github.com/users/judah/repos","events_url":"https://api.github.com/users/judah/events{/privacy}","received_events_url":"https://api.github.com/users/judah/received_events","type":"User","site_admin":false},"body":"Why is this using both the positional and the string-based ways of initializing the dictionary?  (For example, `\"compiler_flags\":...` vs `srcs =...`)","created_at":"2018-05-11T18:26:58Z","updated_at":"2018-05-11T18:36:53Z","html_url":"https://github.com/tweag/rules_haskell/pull/239#discussion_r187696173","pull_request_url":"https://api.github.com/repos/tweag/rules_haskell/pulls/239","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/tweag/rules_haskell/pulls/comments/187696173"},"html":{"href":"https://github.com/tweag/rules_haskell/pull/239#discussion_r187696173"},"pull_request":{"href":"https://api.github.com/repos/tweag/rules_haskell/pulls/239"}}},"pull_request":{"url":"https://api.github.com/repos/tweag/rules_haskell/pulls/239","id":186649555,"html_url":"https://github.com/tweag/rules_haskell/pull/239","diff_url":"https://github.com/tweag/rules_haskell/pull/239.diff","patch_url":"https://github.com/tweag/rules_haskell/pull/239.patch","issue_url":"https://api.github.com/repos/tweag/rules_haskell/issues/239","number":239,"state":"open","locked":false,"title":"Implement protobuf integration using proto-lens","user":{"login":"mrkkrp","id":8165792,"avatar_url":"https://avatars0.githubusercontent.com/u/8165792?v=4","gravatar_id":"","url":"https://api.github.com/users/mrkkrp","html_url":"https://github.com/mrkkrp","followers_url":"https://api.github.com/users/mrkkrp/followers","following_url":"https://api.github.com/users/mrkkrp/following{/other_user}","gists_url":"https://api.github.com/users/mrkkrp/gists{/gist_id}","starred_url":"https://api.github.com/users/mrkkrp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrkkrp/subscriptions","organizations_url":"https://api.github.com/users/mrkkrp/orgs","repos_url":"https://api.github.com/users/mrkkrp/repos","events_url":"https://api.github.com/users/mrkkrp/events{/privacy}","received_events_url":"https://api.github.com/users/mrkkrp/received_events","type":"User","site_admin":false},"body":"This PR adds support for [protocol buffers](https://blog.bazel.build/2017/02/27/protocol-buffers.html) using [`proto-lens`](https://hackage.haskell.org/package/proto-lens).","created_at":"2018-05-08T14:18:15Z","updated_at":"2018-05-11T18:36:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4a8101bf4c311a8499f583665a413edc973b2c9b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/tweag/rules_haskell/pulls/239/commits","review_comments_url":"https://api.github.com/repos/tweag/rules_haskell/pulls/239/comments","review_comment_url":"https://api.github.com/repos/tweag/rules_haskell/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tweag/rules_haskell/issues/239/comments","statuses_url":"https://api.github.com/repos/tweag/rules_haskell/statuses/61a18597f30f00734674028aeeca11d43eabcced","head":{"label":"tweag:protobuf-support","ref":"protobuf-support","sha":"61a18597f30f00734674028aeeca11d43eabcced","user":{"login":"tweag","id":6057932,"avatar_url":"https://avatars3.githubusercontent.com/u/6057932?v=4","gravatar_id":"","url":"https://api.github.com/users/tweag","html_url":"https://github.com/tweag","followers_url":"https://api.github.com/users/tweag/followers","following_url":"https://api.github.com/users/tweag/following{/other_user}","gists_url":"https://api.github.com/users/tweag/gists{/gist_id}","starred_url":"https://api.github.com/users/tweag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tweag/subscriptions","organizations_url":"https://api.github.com/users/tweag/orgs","repos_url":"https://api.github.com/users/tweag/repos","events_url":"https://api.github.com/users/tweag/events{/privacy}","received_events_url":"https://api.github.com/users/tweag/received_events","type":"Organization","site_admin":false},"repo":{"id":109669839,"name":"rules_haskell","full_name":"tweag/rules_haskell","owner":{"login":"tweag","id":6057932,"avatar_url":"https://avatars3.githubusercontent.com/u/6057932?v=4","gravatar_id":"","url":"https://api.github.com/users/tweag","html_url":"https://github.com/tweag","followers_url":"https://api.github.com/users/tweag/followers","following_url":"https://api.github.com/users/tweag/following{/other_user}","gists_url":"https://api.github.com/users/tweag/gists{/gist_id}","starred_url":"https://api.github.com/users/tweag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tweag/subscriptions","organizations_url":"https://api.github.com/users/tweag/orgs","repos_url":"https://api.github.com/users/tweag/repos","events_url":"https://api.github.com/users/tweag/events{/privacy}","received_events_url":"https://api.github.com/users/tweag/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tweag/rules_haskell","description":"Haskell rules for Bazel.","fork":false,"url":"https://api.github.com/repos/tweag/rules_haskell","forks_url":"https://api.github.com/repos/tweag/rules_haskell/forks","keys_url":"https://api.github.com/repos/tweag/rules_haskell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tweag/rules_haskell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tweag/rules_haskell/teams","hooks_url":"https://api.github.com/repos/tweag/rules_haskell/hooks","issue_events_url":"https://api.github.com/repos/tweag/rules_haskell/issues/events{/number}","events_url":"https://api.github.com/repos/tweag/rules_haskell/events","assignees_url":"https://api.github.com/repos/tweag/rules_haskell/assignees{/user}","branches_url":"https://api.github.com/repos/tweag/rules_haskell/branches{/branch}","tags_url":"https://api.github.com/repos/tweag/rules_haskell/tags","blobs_url":"https://api.github.com/repos/tweag/rules_haskell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tweag/rules_haskell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tweag/rules_haskell/git/refs{/sha}","trees_url":"https://api.github.com/repos/tweag/rules_haskell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tweag/rules_haskell/statuses/{sha}","languages_url":"https://api.github.com/repos/tweag/rules_haskell/languages","stargazers_url":"https://api.github.com/repos/tweag/rules_haskell/stargazers","contributors_url":"https://api.github.com/repos/tweag/rules_haskell/contributors","subscribers_url":"https://api.github.com/repos/tweag/rules_haskell/subscribers","subscription_url":"https://api.github.com/repos/tweag/rules_haskell/subscription","commits_url":"https://api.github.com/repos/tweag/rules_haskell/commits{/sha}","git_commits_url":"https://api.github.com/repos/tweag/rules_haskell/git/commits{/sha}","comments_url":"https://api.github.com/repos/tweag/rules_haskell/comments{/number}","issue_comment_url":"https://api.github.com/repos/tweag/rules_haskell/issues/comments{/number}","contents_url":"https://api.github.com/repos/tweag/rules_haskell/contents/{+path}","compare_url":"https://api.github.com/repos/tweag/rules_haskell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tweag/rules_haskell/merges","archive_url":"https://api.github.com/repos/tweag/rules_haskell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tweag/rules_haskell/downloads","issues_url":"https://api.github.com/repos/tweag/rules_haskell/issues{/number}","pulls_url":"https://api.github.com/repos/tweag/rules_haskell/pulls{/number}","milestones_url":"https://api.github.com/repos/tweag/rules_haskell/milestones{/number}","notifications_url":"https://api.github.com/repos/tweag/rules_haskell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tweag/rules_haskell/labels{/name}","releases_url":"https://api.github.com/repos/tweag/rules_haskell/releases{/id}","deployments_url":"https://api.github.com/repos/tweag/rules_haskell/deployments","created_at":"2017-11-06T08:50:01Z","updated_at":"2018-05-10T09:24:57Z","pushed_at":"2018-05-11T14:06:16Z","git_url":"git://github.com/tweag/rules_haskell.git","ssh_url":"git@github.com:tweag/rules_haskell.git","clone_url":"https://github.com/tweag/rules_haskell.git","svn_url":"https://github.com/tweag/rules_haskell","homepage":null,"size":482,"stargazers_count":58,"watchers_count":58,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":29,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":13,"open_issues":29,"watchers":58,"default_branch":"master"}},"base":{"label":"tweag:master","ref":"master","sha":"2cb9f2d7f946a70070207faf130e9e3b88b6bd09","user":{"login":"tweag","id":6057932,"avatar_url":"https://avatars3.githubusercontent.com/u/6057932?v=4","gravatar_id":"","url":"https://api.github.com/users/tweag","html_url":"https://github.com/tweag","followers_url":"https://api.github.com/users/tweag/followers","following_url":"https://api.github.com/users/tweag/following{/other_user}","gists_url":"https://api.github.com/users/tweag/gists{/gist_id}","starred_url":"https://api.github.com/users/tweag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tweag/subscriptions","organizations_url":"https://api.github.com/users/tweag/orgs","repos_url":"https://api.github.com/users/tweag/repos","events_url":"https://api.github.com/users/tweag/events{/privacy}","received_events_url":"https://api.github.com/users/tweag/received_events","type":"Organization","site_admin":false},"repo":{"id":109669839,"name":"rules_haskell","full_name":"tweag/rules_haskell","owner":{"login":"tweag","id":6057932,"avatar_url":"https://avatars3.githubusercontent.com/u/6057932?v=4","gravatar_id":"","url":"https://api.github.com/users/tweag","html_url":"https://github.com/tweag","followers_url":"https://api.github.com/users/tweag/followers","following_url":"https://api.github.com/users/tweag/following{/other_user}","gists_url":"https://api.github.com/users/tweag/gists{/gist_id}","starred_url":"https://api.github.com/users/tweag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tweag/subscriptions","organizations_url":"https://api.github.com/users/tweag/orgs","repos_url":"https://api.github.com/users/tweag/repos","events_url":"https://api.github.com/users/tweag/events{/privacy}","received_events_url":"https://api.github.com/users/tweag/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tweag/rules_haskell","description":"Haskell rules for Bazel.","fork":false,"url":"https://api.github.com/repos/tweag/rules_haskell","forks_url":"https://api.github.com/repos/tweag/rules_haskell/forks","keys_url":"https://api.github.com/repos/tweag/rules_haskell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tweag/rules_haskell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tweag/rules_haskell/teams","hooks_url":"https://api.github.com/repos/tweag/rules_haskell/hooks","issue_events_url":"https://api.github.com/repos/tweag/rules_haskell/issues/events{/number}","events_url":"https://api.github.com/repos/tweag/rules_haskell/events","assignees_url":"https://api.github.com/repos/tweag/rules_haskell/assignees{/user}","branches_url":"https://api.github.com/repos/tweag/rules_haskell/branches{/branch}","tags_url":"https://api.github.com/repos/tweag/rules_haskell/tags","blobs_url":"https://api.github.com/repos/tweag/rules_haskell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tweag/rules_haskell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tweag/rules_haskell/git/refs{/sha}","trees_url":"https://api.github.com/repos/tweag/rules_haskell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tweag/rules_haskell/statuses/{sha}","languages_url":"https://api.github.com/repos/tweag/rules_haskell/languages","stargazers_url":"https://api.github.com/repos/tweag/rules_haskell/stargazers","contributors_url":"https://api.github.com/repos/tweag/rules_haskell/contributors","subscribers_url":"https://api.github.com/repos/tweag/rules_haskell/subscribers","subscription_url":"https://api.github.com/repos/tweag/rules_haskell/subscription","commits_url":"https://api.github.com/repos/tweag/rules_haskell/commits{/sha}","git_commits_url":"https://api.github.com/repos/tweag/rules_haskell/git/commits{/sha}","comments_url":"https://api.github.com/repos/tweag/rules_haskell/comments{/number}","issue_comment_url":"https://api.github.com/repos/tweag/rules_haskell/issues/comments{/number}","contents_url":"https://api.github.com/repos/tweag/rules_haskell/contents/{+path}","compare_url":"https://api.github.com/repos/tweag/rules_haskell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tweag/rules_haskell/merges","archive_url":"https://api.github.com/repos/tweag/rules_haskell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tweag/rules_haskell/downloads","issues_url":"https://api.github.com/repos/tweag/rules_haskell/issues{/number}","pulls_url":"https://api.github.com/repos/tweag/rules_haskell/pulls{/number}","milestones_url":"https://api.github.com/repos/tweag/rules_haskell/milestones{/number}","notifications_url":"https://api.github.com/repos/tweag/rules_haskell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tweag/rules_haskell/labels{/name}","releases_url":"https://api.github.com/repos/tweag/rules_haskell/releases{/id}","deployments_url":"https://api.github.com/repos/tweag/rules_haskell/deployments","created_at":"2017-11-06T08:50:01Z","updated_at":"2018-05-10T09:24:57Z","pushed_at":"2018-05-11T14:06:16Z","git_url":"git://github.com/tweag/rules_haskell.git","ssh_url":"git@github.com:tweag/rules_haskell.git","clone_url":"https://github.com/tweag/rules_haskell.git","svn_url":"https://github.com/tweag/rules_haskell","homepage":null,"size":482,"stargazers_count":58,"watchers_count":58,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":29,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":13,"open_issues":29,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tweag/rules_haskell/pulls/239"},"html":{"href":"https://github.com/tweag/rules_haskell/pull/239"},"issue":{"href":"https://api.github.com/repos/tweag/rules_haskell/issues/239"},"comments":{"href":"https://api.github.com/repos/tweag/rules_haskell/issues/239/comments"},"review_comments":{"href":"https://api.github.com/repos/tweag/rules_haskell/pulls/239/comments"},"review_comment":{"href":"https://api.github.com/repos/tweag/rules_haskell/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tweag/rules_haskell/pulls/239/commits"},"statuses":{"href":"https://api.github.com/repos/tweag/rules_haskell/statuses/61a18597f30f00734674028aeeca11d43eabcced"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"judah"}}