Adding to Pair docs #114

Merged
merged 1 commit into from Jun 7, 2017
Jump to file or symbol
Failed to load files and symbols.
+15 −1
Split
View
16 SPEC.md
@@ -18,6 +18,7 @@
* [Operator Precedence Table](#operator-precedence-table)
* [Member Access](#member-access)
* [Map and Array Indexing](#map-and-array-indexing)
+ * [Pair Indexing](#pair-indexing)
* [Function Calls](#function-calls)
* [Array Literals](#array-literals)
* [Map Literals](#map-literals)
@@ -592,6 +593,12 @@ workflow wf {
The syntax `x[y]` is for indexing maps and arrays. If `x` is an array, then `y` must evaluate to an integer. If `x` is a map, then `y` must evaluate to a key in that map.
+### Pair Indexing
+
+:pig2: [Cromwell supported](https://github.com/broadinstitute/cromwell#wdl-support) :white_check_mark:
+
+Given a Pair `x`, the left and right elements of that type can be accessed using the syntax `x.left` and `x.right`.
+
### Function Calls
:pig2: [Cromwell supported](https://github.com/broadinstitute/cromwell#wdl-support) :white_check_mark:
@@ -626,12 +633,19 @@ Map[String, Int] = {"a": 1, "b": 2}
:pig2: [Cromwell supported](https://github.com/broadinstitute/cromwell#wdl-support) :white_check_mark:
-Pair values can be specified using another Python-like syntax, as follows:
+Pair values can be specified inside of a WDL using another Python-like syntax, as follows:
```
Pair[Int, String] twenty_threes = (23, "twenty-three")
```
+Pair values can also be specified within the [workflow inputs JSON](https://github.com/broadinstitute/wdl/blob/develop/SPEC.md#specifying-workflow-inputs-in-json) with a `Left` and `Right` value specified using JSON style syntax. For example, given a workflow `wf_hello` and workflow-level variable `twenty_threes`, it could be declared in the workflow inputs JSON as follows:
+```
+{
+ "wf_hello.twenty_threes": { "Left": 23, "Right": "twenty-three" }
@cjllanwarne

cjllanwarne Jun 7, 2017 edited

Contributor

Are those Left and Right capitalizations correct? I think in the output it's all lowercase?

@ruchim

ruchim Jun 7, 2017

Contributor

Json to Pair coercion isn't sensitive towards capitalization (there's a test case in WDL4S for it) but I didn't realize the outputs were all lowercase, that creates a slight inconsistency. We could make it required lowercase for the future but currently Pair creation accepts "Left" or "left"

+}
+```
+
## Document
:pig2: [Cromwell supported](https://github.com/broadinstitute/cromwell#wdl-support) :white_check_mark: