{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/comments/186774707","pull_request_review_id":118414576,"id":186774707,"diff_hunk":"@@ -0,0 +1,450 @@\n+package wdl.draft3.transforms.wdlom2wdl\n+\n+import simulacrum.typeclass\n+import wdl.model.draft3.elements.CommandPartElement.{PlaceholderCommandPartElement, StringCommandPartElement}\n+import wdl.model.draft3.elements.ExpressionElement._\n+import wdl.model.draft3.elements.MetaValueElement._\n+import wdl.model.draft3.elements._\n+import wom.types._\n+\n+import scala.language.implicitConversions\n+\n+@typeclass\n+trait WdlWriter[A] {\n+  def toWdl(a: A): String\n+\n+  // Stolen from WomGraph.scala\n+  def indent(s: String) = s.lines.map(x => s\"  $x\").mkString(System.lineSeparator)\n+  def combine(ss: Iterable[String]) = ss.mkString(start=\"\", sep=System.lineSeparator, end=System.lineSeparator)\n+  def indentAndCombine(ss: Iterable[String]) = combine(ss.map(indent))\n+}\n+\n+object WdlWriter {\n+\n+  // Auto-generated by simulacrum\n+  import WdlWriter.ops._\n+\n+  implicit val ifWriter: WdlWriter[IfElement] = new WdlWriter[IfElement] {\n+    override def toWdl(a: IfElement) = {\n+      s\"\"\"if (${a.conditionExpression.toWdl}) {\n+         |${indentAndCombine(a.graphElements.map(_.toWdl))}}\"\"\".stripMargin\n+    }\n+  }\n+\n+  implicit val stringPieceWriter: WdlWriter[StringPiece] = new WdlWriter[StringPiece] {\n+    override def toWdl(a: StringPiece): String = a match {\n+      case a: StringLiteral     => a.value\n+      case a: StringPlaceholder => \"~{\" + a.expr.toWdl + \"}\"\n+    }\n+  }\n+\n+  // Recursive references must be explicit\n+  implicit val expressionElementWriter: WdlWriter[ExpressionElement] = new WdlWriter[ExpressionElement] {\n+    override def toWdl(a: ExpressionElement) = a match {\n+      case a: PrimitiveLiteralExpressionElement => a.toWdl\n+      case a: StringExpression => \"\\\"\" + a.pieces.map(_.toWdl).mkString + \"\\\"\"\n+      case a: StringLiteral => \"\\\"\" + a.value + \"\\\"\"\n+      case a: ObjectLiteral =>\n+        \"object { \" + a.elements.map { pair =>\n+          pair._1 + \": \" + expressionElementWriter.toWdl(pair._2)\n+        }.mkString(\", \") + \" }\"\n+      case a: ArrayLiteral =>\n+        \"[\" + a.elements.map(expressionElementWriter.toWdl).mkString(\", \") + \"]\"\n+      case a: MapLiteral =>\n+        \"{ \" + a.elements.map { pair =>\n+          expressionElementWriter.toWdl(pair._1) + \": \" + expressionElementWriter.toWdl(pair._2)\n+        }.mkString(\", \") + \" }\"\n+      case a: PairLiteral =>\n+        s\"(${expressionElementWriter.toWdl(a.left)}, ${expressionElementWriter.toWdl(a.right)})\"\n+      case a: UnaryOperation => a.toWdl\n+      case a: BinaryOperation => a.toWdl\n+      case a: TernaryIf =>\n+        s\"if ${expressionElementWriter.toWdl(a.condition)} then ${expressionElementWriter.toWdl(a.ifTrue)} else ${expressionElementWriter.toWdl(a.ifFalse)}\"\n+      case a: FunctionCallElement => a.toWdl\n+      case a: IdentifierLookup => a.identifier\n+      case a: IdentifierMemberAccess => a.toWdl\n+      case a: ExpressionMemberAccess => s\"${expressionElementWriter.toWdl(a.expression)}.${a.memberAccessTail.toList.mkString(\".\")}\"\n+      case a: IndexAccess => s\"${expressionElementWriter.toWdl(a.expressionElement)}[${expressionElementWriter.toWdl(a.index)}]\"\n+    }\n+  }\n+\n+  implicit val unaryOperationWriter: WdlWriter[UnaryOperation] = new WdlWriter[UnaryOperation] {\n+    override def toWdl(a: UnaryOperation): String = a match {\n+      case a: LogicalNot    => s\"!(${a.argument.toWdl})\"\n+      case a: UnaryNegation => \"-\" + a.argument.toWdl\n+      case a: UnaryPlus     => \"+\" + a.argument.toWdl\n+    }\n+  }\n+\n+  implicit val identifierMemberAccessWriter: WdlWriter[IdentifierMemberAccess] = new WdlWriter[IdentifierMemberAccess] {\n+    override def toWdl(a: IdentifierMemberAccess): String = {\n+      s\"${a.first}.${a.second}\" + (if (a.memberAccessTail.nonEmpty) {\n+        \".\" + a.memberAccessTail.mkString(\".\")\n+      } else {\n+        \"\"\n+      })\n+    }\n+  }\n+\n+  implicit val binaryOperationWriter: WdlWriter[BinaryOperation] = new WdlWriter[BinaryOperation] {\n+    override def toWdl(a: BinaryOperation) = {\n+      def sandwich(opString: String) = s\"${a.left.toWdl} $opString ${a.right.toWdl}\"\n+\n+      a match {\n+        case _: LogicalOr           => sandwich(\"||\")\n+        case _: LogicalAnd          => sandwich(\"&&\")\n+        case _: Equals              => sandwich(\"==\")\n+        case _: NotEquals           => sandwich(\"!=\")\n+        case _: LessThan            => sandwich(\"< \")\n+        case _: LessThanOrEquals    => sandwich(\"<=\")\n+        case _: GreaterThan         => sandwich(\"> \")","path":"wdl/transforms/draft3/src/main/scala/wdl/draft3/transforms/wdlom2wdl/WdlWriter.scala","position":100,"original_position":100,"commit_id":"b0ce82047c02df8bc1ec9e11abe09b5e4b9b282f","original_commit_id":"87f8d01b0920e27727b79cc5a69426ab4232ba17","user":{"login":"cjllanwarne","id":13006282,"avatar_url":"https://avatars1.githubusercontent.com/u/13006282?v=4","gravatar_id":"","url":"https://api.github.com/users/cjllanwarne","html_url":"https://github.com/cjllanwarne","followers_url":"https://api.github.com/users/cjllanwarne/followers","following_url":"https://api.github.com/users/cjllanwarne/following{/other_user}","gists_url":"https://api.github.com/users/cjllanwarne/gists{/gist_id}","starred_url":"https://api.github.com/users/cjllanwarne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjllanwarne/subscriptions","organizations_url":"https://api.github.com/users/cjllanwarne/orgs","repos_url":"https://api.github.com/users/cjllanwarne/repos","events_url":"https://api.github.com/users/cjllanwarne/events{/privacy}","received_events_url":"https://api.github.com/users/cjllanwarne/received_events","type":"User","site_admin":false},"body":"Just OOI, is the extra space here deliberate?","created_at":"2018-05-08T15:43:36Z","updated_at":"2018-05-08T15:54:04Z","html_url":"https://github.com/broadinstitute/cromwell/pull/3601#discussion_r186774707","pull_request_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/3601","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/comments/186774707"},"html":{"href":"https://github.com/broadinstitute/cromwell/pull/3601#discussion_r186774707"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/3601"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/3601","id":186474247,"html_url":"https://github.com/broadinstitute/cromwell/pull/3601","diff_url":"https://github.com/broadinstitute/cromwell/pull/3601.diff","patch_url":"https://github.com/broadinstitute/cromwell/pull/3601.patch","issue_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/3601","number":3601,"state":"open","locked":false,"title":"WDL 1.0 upgrade script Phase I: WDL writer","user":{"login":"aednichols","id":1087943,"avatar_url":"https://avatars3.githubusercontent.com/u/1087943?v=4","gravatar_id":"","url":"https://api.github.com/users/aednichols","html_url":"https://github.com/aednichols","followers_url":"https://api.github.com/users/aednichols/followers","following_url":"https://api.github.com/users/aednichols/following{/other_user}","gists_url":"https://api.github.com/users/aednichols/gists{/gist_id}","starred_url":"https://api.github.com/users/aednichols/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aednichols/subscriptions","organizations_url":"https://api.github.com/users/aednichols/orgs","repos_url":"https://api.github.com/users/aednichols/repos","events_url":"https://api.github.com/users/aednichols/events{/privacy}","received_events_url":"https://api.github.com/users/aednichols/received_events","type":"User","site_admin":false},"body":"Takes WDL 1.0 case classes (`wdl.model.draft3.elements.FileElement` and its children) and writes them out as WDL source code.\r\n\r\nTest scheme:\r\n1. Load the WDL as case classes\r\n2. Write them out as source\r\n3. Load up the source from step 2 as case classes\r\n4. Verify the case classes from (1) and (3) are identical\r\n\r\nI also uncovered some gaps in the set of WDLs we use for unit tests - I had gotten all the tests to pass, but there were still a handful of `???`'s in my code. Added test cases such that all of them were hit (and then implemented).","created_at":"2018-05-07T21:48:50Z","updated_at":"2018-05-08T15:54:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"49fa8a5d262c87ac9f3d8ebf58c3a5dfc007130c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":835331548,"url":"https://api.github.com/repos/broadinstitute/cromwell/labels/%F0%9F%8C%B2Redwood","name":"🌲Redwood","color":"a45a52","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/3601/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/3601/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/3601/comments","statuses_url":"https://api.github.com/repos/broadinstitute/cromwell/statuses/b0ce82047c02df8bc1ec9e11abe09b5e4b9b282f","head":{"label":"broadinstitute:an_d3_upgrade","ref":"an_d3_upgrade","sha":"b0ce82047c02df8bc1ec9e11abe09b5e4b9b282f","user":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars0.githubusercontent.com/u/393552?v=4","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"repo":{"id":34136406,"name":"cromwell","full_name":"broadinstitute/cromwell","owner":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars0.githubusercontent.com/u/393552?v=4","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/broadinstitute/cromwell","description":"Scientific workflow engine designed for simplicity & scalability. Trivially transition between one off use cases to massive scale production environments","fork":false,"url":"https://api.github.com/repos/broadinstitute/cromwell","forks_url":"https://api.github.com/repos/broadinstitute/cromwell/forks","keys_url":"https://api.github.com/repos/broadinstitute/cromwell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/cromwell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/cromwell/teams","hooks_url":"https://api.github.com/repos/broadinstitute/cromwell/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/cromwell/events","assignees_url":"https://api.github.com/repos/broadinstitute/cromwell/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/cromwell/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/cromwell/tags","blobs_url":"https://api.github.com/repos/broadinstitute/cromwell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/cromwell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/cromwell/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/cromwell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/cromwell/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/cromwell/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/cromwell/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/cromwell/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/cromwell/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/cromwell/subscription","commits_url":"https://api.github.com/repos/broadinstitute/cromwell/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/cromwell/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/cromwell/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/cromwell/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/cromwell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/cromwell/merges","archive_url":"https://api.github.com/repos/broadinstitute/cromwell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/cromwell/downloads","issues_url":"https://api.github.com/repos/broadinstitute/cromwell/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/cromwell/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/cromwell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/cromwell/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/cromwell/releases{/id}","deployments_url":"https://api.github.com/repos/broadinstitute/cromwell/deployments","created_at":"2015-04-17T19:39:36Z","updated_at":"2018-05-08T15:04:40Z","pushed_at":"2018-05-08T15:44:04Z","git_url":"git://github.com/broadinstitute/cromwell.git","ssh_url":"git@github.com:broadinstitute/cromwell.git","clone_url":"https://github.com/broadinstitute/cromwell.git","svn_url":"https://github.com/broadinstitute/cromwell","homepage":"http://cromwell.readthedocs.io/en/develop","size":18221,"stargazers_count":247,"watchers_count":247,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":70,"mirror_url":null,"archived":false,"open_issues_count":476,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":70,"open_issues":476,"watchers":247,"default_branch":"develop"}},"base":{"label":"broadinstitute:develop","ref":"develop","sha":"56c588649e1a9196ec3c07426931d8f5240042d6","user":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars0.githubusercontent.com/u/393552?v=4","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"repo":{"id":34136406,"name":"cromwell","full_name":"broadinstitute/cromwell","owner":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars0.githubusercontent.com/u/393552?v=4","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/broadinstitute/cromwell","description":"Scientific workflow engine designed for simplicity & scalability. Trivially transition between one off use cases to massive scale production environments","fork":false,"url":"https://api.github.com/repos/broadinstitute/cromwell","forks_url":"https://api.github.com/repos/broadinstitute/cromwell/forks","keys_url":"https://api.github.com/repos/broadinstitute/cromwell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/cromwell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/cromwell/teams","hooks_url":"https://api.github.com/repos/broadinstitute/cromwell/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/cromwell/events","assignees_url":"https://api.github.com/repos/broadinstitute/cromwell/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/cromwell/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/cromwell/tags","blobs_url":"https://api.github.com/repos/broadinstitute/cromwell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/cromwell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/cromwell/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/cromwell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/cromwell/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/cromwell/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/cromwell/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/cromwell/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/cromwell/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/cromwell/subscription","commits_url":"https://api.github.com/repos/broadinstitute/cromwell/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/cromwell/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/cromwell/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/cromwell/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/cromwell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/cromwell/merges","archive_url":"https://api.github.com/repos/broadinstitute/cromwell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/cromwell/downloads","issues_url":"https://api.github.com/repos/broadinstitute/cromwell/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/cromwell/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/cromwell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/cromwell/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/cromwell/releases{/id}","deployments_url":"https://api.github.com/repos/broadinstitute/cromwell/deployments","created_at":"2015-04-17T19:39:36Z","updated_at":"2018-05-08T15:04:40Z","pushed_at":"2018-05-08T15:44:04Z","git_url":"git://github.com/broadinstitute/cromwell.git","ssh_url":"git@github.com:broadinstitute/cromwell.git","clone_url":"https://github.com/broadinstitute/cromwell.git","svn_url":"https://github.com/broadinstitute/cromwell","homepage":"http://cromwell.readthedocs.io/en/develop","size":18221,"stargazers_count":247,"watchers_count":247,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":70,"mirror_url":null,"archived":false,"open_issues_count":476,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":70,"open_issues":476,"watchers":247,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/3601"},"html":{"href":"https://github.com/broadinstitute/cromwell/pull/3601"},"issue":{"href":"https://api.github.com/repos/broadinstitute/cromwell/issues/3601"},"comments":{"href":"https://api.github.com/repos/broadinstitute/cromwell/issues/3601/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/3601/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/3601/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/cromwell/statuses/b0ce82047c02df8bc1ec9e11abe09b5e4b9b282f"}},"author_association":"NONE"}}
{"actor":{"display_login":"cjllanwarne"}}