Core concepts
This page explains how Chute language features map to Siri Shortcuts actions and data.
Variables are magic variables
In Shortcuts, every action's output becomes a magic variable that later actions can reference. In Chute, you use const and let instead.
import Notification;
shortcut { name: "Variables" }
const greeting = "Hello";
Notification.showAlert(greeting);<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>WFWorkflowClientVersion</key>
<string>1</string>
<key>WFWorkflowHasOutputFallback</key>
<false/>
<key>WFWorkflowHasShortcutInputVariables</key>
<false/>
<key>WFWorkflowIcon</key>
<dict>
<key>WFWorkflowIconGlyphNumber</key>
<integer>59511</integer>
<key>WFWorkflowIconStartColor</key>
<integer>4274264319</integer>
</dict>
<key>WFWorkflowImportQuestions</key>
<array/>
<key>WFWorkflowInputContentItemClasses</key>
<array/>
<key>WFWorkflowMinimumClientVersion</key>
<integer>900</integer>
<key>WFWorkflowMinimumClientVersionString</key>
<string>900</string>
<key>WFWorkflowName</key>
<string>Variables</string>
<key>WFWorkflowTypes</key>
<array>
<string>NCWidget</string>
<string>WatchKit</string>
</array>
<key>WFWorkflowActions</key>
<array>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.gettext</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000000</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFTextActionText</key>
<string>Hello</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000001</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>greeting</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.alert</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000002</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFAlertActionMessage</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>greeting</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</dict>
</array>
</dict>
</plist>
const creates an immutable binding. The compiler translates it into a "Set Variable" action, and any reference to greeting becomes a "Get Variable" action that retrieves the stored value.
Use let when you need to reassign a variable:
let count = 0;
count = count + 1;For more details, see Variables and bindings.
Functions
Chute functions have typed parameters and return values. The compiler includes each function in the same shortcut file. A function call becomes a "Run Shortcut" action that targets that shortcut.
import Notification;
shortcut { name: "Functions" }
func double(n: Number) -> Number {
return n * 2;
}
const result = double(5);
Notification.showResult("${result}");<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>WFWorkflowClientVersion</key>
<string>1</string>
<key>WFWorkflowHasOutputFallback</key>
<false/>
<key>WFWorkflowHasShortcutInputVariables</key>
<true/>
<key>WFWorkflowIcon</key>
<dict>
<key>WFWorkflowIconGlyphNumber</key>
<integer>59511</integer>
<key>WFWorkflowIconStartColor</key>
<integer>4274264319</integer>
</dict>
<key>WFWorkflowImportQuestions</key>
<array/>
<key>WFWorkflowInputContentItemClasses</key>
<array>
<string>WFContentItem</string>
</array>
<key>WFWorkflowMinimumClientVersion</key>
<integer>900</integer>
<key>WFWorkflowMinimumClientVersionString</key>
<string>900</string>
<key>WFWorkflowName</key>
<string>Functions</string>
<key>WFWorkflowTypes</key>
<array>
<string>NCWidget</string>
<string>WatchKit</string>
</array>
<key>WFWorkflowActions</key>
<array>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000000</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFInput</key>
<dict>
<key>Value</key>
<dict>
<key>Type</key>
<string>ExtensionInput</string>
</dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
</dict>
<key>WFVariableName</key>
<string>__chute_tmp_0</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000001</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_0</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvalueforkey</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000002</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFDictionaryKey</key>
<string>__chute_fn</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000003</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_1</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000005</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_1</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.conditional</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000006</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFCondition</key>
<integer>100</integer>
<key>WFInput</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>Variable</key>
<dict>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_1</string>
</dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
</dict>
</dict>
<key>WFControlFlowMode</key>
<integer>0</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000004</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.gettext</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000007</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFTextActionText</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_1</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000008</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_2</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000010</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_2</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.conditional</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000011</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFCondition</key>
<integer>4</integer>
<key>WFConditionalActionString</key>
<string>double</string>
<key>WFInput</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>Variable</key>
<dict>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_2</string>
</dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
</dict>
</dict>
<key>WFControlFlowMode</key>
<integer>0</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000009</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000012</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_0</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvalueforkey</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000013</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFDictionaryKey</key>
<string>n</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000014</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>n</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000015</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>n</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.math</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000016</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFMathOperation</key>
<string>×</string>
<key>WFMathOperand</key>
<integer>2</integer>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000017</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_3</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.output</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000018</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFOutput</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_3</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.conditional</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000019</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFControlFlowMode</key>
<integer>2</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000009</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.conditional</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000020</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFControlFlowMode</key>
<integer>2</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000004</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.dictionary</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000021</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFItems</key>
<dict>
<key>Value</key>
<dict>
<key>WFDictionaryFieldValueItems</key>
<array>
<dict>
<key>WFItemType</key>
<integer>0</integer>
<key>WFKey</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>__chute_fn</string>
</dict>
</dict>
<key>WFValue</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>double</string>
</dict>
</dict>
</dict>
<dict>
<key>WFItemType</key>
<integer>3</integer>
<key>WFKey</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>n</string>
</dict>
</dict>
<key>WFValue</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>5</string>
<key>attachmentsByRange</key>
<dict/>
</dict>
</dict>
</dict>
</array>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000022</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_4</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.runworkflow</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000023</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFWorkflow</key>
<dict>
<key>isSelf</key>
<true/>
<key>workflowName</key>
<string>Functions</string>
</dict>
<key>WFInput</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_4</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000024</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>result</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.showresult</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000025</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>Text</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>result</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</dict>
</array>
</dict>
</plist>
For more details, see Functions.
Actions map to Shortcuts actions
The action keyword binds a Chute function name to a Shortcuts action identifier. Standard library functions such as Notification.showAlert and Device.getClipboard use action declarations.
Here's what the standard library's showAlert looks like internally:
action showAlert(text WFAlertActionTitle: Text) = "is.workflow.actions.alert";This declaration tells the compiler three things:
- The Chute function name is
showAlert. - The parameter
textmaps to the Shortcuts parameter keyWFAlertActionTitle. - The underlying action identifier is
is.workflow.actions.alert.
You can declare your own actions to call Shortcuts actions that aren't in the standard library. For more details, see Actions.
Control flow compiles to Shortcuts blocks
Chute's control flow statements map directly to their Shortcuts equivalents:
| Chute | Shortcuts equivalent |
|---|---|
if/else | If / Otherwise |
for item in list | Repeat with Each |
repeat N | Repeat |
menu "prompt" | Choose from Menu |
import Notification;
shortcut { name: "ControlFlow" }
const items = ["apples", "bananas", "cherries"];
for item in items {
Notification.showAlert(item);
}<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>WFWorkflowClientVersion</key>
<string>1</string>
<key>WFWorkflowHasOutputFallback</key>
<false/>
<key>WFWorkflowHasShortcutInputVariables</key>
<false/>
<key>WFWorkflowIcon</key>
<dict>
<key>WFWorkflowIconGlyphNumber</key>
<integer>59511</integer>
<key>WFWorkflowIconStartColor</key>
<integer>4274264319</integer>
</dict>
<key>WFWorkflowImportQuestions</key>
<array/>
<key>WFWorkflowInputContentItemClasses</key>
<array/>
<key>WFWorkflowMinimumClientVersion</key>
<integer>900</integer>
<key>WFWorkflowMinimumClientVersionString</key>
<string>900</string>
<key>WFWorkflowName</key>
<string>ControlFlow</string>
<key>WFWorkflowTypes</key>
<array>
<string>NCWidget</string>
<string>WatchKit</string>
</array>
<key>WFWorkflowActions</key>
<array>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.list</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000000</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFItems</key>
<array>
<dict>
<key>WFItemType</key>
<integer>0</integer>
<key>WFValue</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>apples</string>
</dict>
</dict>
</dict>
<dict>
<key>WFItemType</key>
<integer>0</integer>
<key>WFValue</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>bananas</string>
</dict>
</dict>
</dict>
<dict>
<key>WFItemType</key>
<integer>0</integer>
<key>WFValue</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>cherries</string>
</dict>
</dict>
</dict>
</array>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000001</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>items</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000003</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>items</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.repeat.each</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000004</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFControlFlowMode</key>
<integer>0</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000002</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000005</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>item</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.alert</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000006</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFAlertActionMessage</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>item</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.repeat.each</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000007</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFControlFlowMode</key>
<integer>2</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000002</string>
</dict>
</dict>
</array>
</dict>
</plist>
The for loop compiles to a "Repeat with Each" action. The loop variable item references the "Repeat Item" magic variable that Shortcuts provides inside the loop.
For more details, see Control flow.
The type system catches errors at compile time
Shortcuts doesn't check these types before running an action. An incompatible output can therefore cause a runtime error.
Chute's type system catches these mistakes before the shortcut is compiled. The built-in types are:
| Type | Description |
|---|---|
Text | A string of characters. |
Number | An integer or decimal number. |
Boolean | true or false. |
List<T> | An ordered list where every element has type T. |
Dictionary | A key-value dictionary. |
Quantity<unit> | A measurement with a unit, such as Quantity<seconds>. |
Chute also supports optionals. A Number? can hold a number or nil, and the compiler enforces that you handle the nil case before using the value.
For more details, see Types.
Pipelines chain operations
In Shortcuts, you chain actions by connecting one action's output to the next action's input. Chute's pipeline operator (|>) does the same thing in code.
import Notification;
shortcut { name: "Pipelines" }
func double(n: Number) -> Number { return n * 2; }
func triple(n: Number) -> Number { return n * 3; }
const x = 5 |> double |> triple;
Notification.showResult("${x}");<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>WFWorkflowClientVersion</key>
<string>1</string>
<key>WFWorkflowHasOutputFallback</key>
<false/>
<key>WFWorkflowHasShortcutInputVariables</key>
<true/>
<key>WFWorkflowIcon</key>
<dict>
<key>WFWorkflowIconGlyphNumber</key>
<integer>59511</integer>
<key>WFWorkflowIconStartColor</key>
<integer>4274264319</integer>
</dict>
<key>WFWorkflowImportQuestions</key>
<array/>
<key>WFWorkflowInputContentItemClasses</key>
<array>
<string>WFContentItem</string>
</array>
<key>WFWorkflowMinimumClientVersion</key>
<integer>900</integer>
<key>WFWorkflowMinimumClientVersionString</key>
<string>900</string>
<key>WFWorkflowName</key>
<string>Pipelines</string>
<key>WFWorkflowTypes</key>
<array>
<string>NCWidget</string>
<string>WatchKit</string>
</array>
<key>WFWorkflowActions</key>
<array>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000000</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFInput</key>
<dict>
<key>Value</key>
<dict>
<key>Type</key>
<string>ExtensionInput</string>
</dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
</dict>
<key>WFVariableName</key>
<string>__chute_tmp_0</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000001</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_0</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvalueforkey</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000002</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFDictionaryKey</key>
<string>__chute_fn</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000003</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_1</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000005</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_1</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.conditional</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000006</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFCondition</key>
<integer>100</integer>
<key>WFInput</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>Variable</key>
<dict>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_1</string>
</dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
</dict>
</dict>
<key>WFControlFlowMode</key>
<integer>0</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000004</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.gettext</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000007</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFTextActionText</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_1</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000008</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_2</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000010</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_2</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.conditional</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000011</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFCondition</key>
<integer>4</integer>
<key>WFConditionalActionString</key>
<string>double</string>
<key>WFInput</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>Variable</key>
<dict>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_2</string>
</dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
</dict>
</dict>
<key>WFControlFlowMode</key>
<integer>0</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000009</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000012</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_0</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvalueforkey</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000013</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFDictionaryKey</key>
<string>n</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000014</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>n</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000015</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>n</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.math</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000016</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFMathOperation</key>
<string>×</string>
<key>WFMathOperand</key>
<integer>2</integer>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000017</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_3</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.output</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000018</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFOutput</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_3</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.conditional</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000019</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFControlFlowMode</key>
<integer>2</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000009</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000021</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_2</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.conditional</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000022</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFCondition</key>
<integer>4</integer>
<key>WFConditionalActionString</key>
<string>triple</string>
<key>WFInput</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>Variable</key>
<dict>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_2</string>
</dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
</dict>
</dict>
<key>WFControlFlowMode</key>
<integer>0</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000020</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000023</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_0</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvalueforkey</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000024</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFDictionaryKey</key>
<string>n</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000025</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>n</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.getvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000026</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariable</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>n</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.math</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000027</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFMathOperation</key>
<string>×</string>
<key>WFMathOperand</key>
<integer>3</integer>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000028</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_4</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.output</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000029</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFOutput</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_4</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.conditional</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000030</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFControlFlowMode</key>
<integer>2</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000020</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.conditional</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000031</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFControlFlowMode</key>
<integer>2</integer>
<key>GroupingIdentifier</key>
<string>00000000-0000-0000-0000-000000000004</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.number</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000032</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFNumberActionNumber</key>
<integer>5</integer>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000033</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_5</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.dictionary</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000034</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFItems</key>
<dict>
<key>Value</key>
<dict>
<key>WFDictionaryFieldValueItems</key>
<array>
<dict>
<key>WFItemType</key>
<integer>0</integer>
<key>WFKey</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>n</string>
</dict>
</dict>
<key>WFValue</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_5</string>
</dict>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFItemType</key>
<integer>0</integer>
<key>WFKey</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>__chute_fn</string>
</dict>
</dict>
<key>WFValue</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>double</string>
</dict>
</dict>
</dict>
</array>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000035</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_6</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.runworkflow</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000036</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFWorkflow</key>
<dict>
<key>isSelf</key>
<true/>
<key>workflowName</key>
<string>Pipelines</string>
</dict>
<key>WFInput</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_6</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000037</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_7</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.dictionary</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000038</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFItems</key>
<dict>
<key>Value</key>
<dict>
<key>WFDictionaryFieldValueItems</key>
<array>
<dict>
<key>WFItemType</key>
<integer>0</integer>
<key>WFKey</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>n</string>
</dict>
</dict>
<key>WFValue</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_7</string>
</dict>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFItemType</key>
<integer>0</integer>
<key>WFKey</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>__chute_fn</string>
</dict>
</dict>
<key>WFValue</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string>triple</string>
</dict>
</dict>
</dict>
</array>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000039</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>__chute_tmp_8</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.runworkflow</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000040</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFWorkflow</key>
<dict>
<key>isSelf</key>
<true/>
<key>workflowName</key>
<string>Pipelines</string>
</dict>
<key>WFInput</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenAttachment</string>
<key>Value</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>__chute_tmp_8</string>
</dict>
</dict>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.setvariable</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000041</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFVariableName</key>
<string>x</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.showresult</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000042</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>Text</key>
<dict>
<key>WFSerializationType</key>
<string>WFTextTokenString</string>
<key>Value</key>
<dict>
<key>string</key>
<string></string>
<key>attachmentsByRange</key>
<dict>
<key>{0, 1}</key>
<dict>
<key>Type</key>
<string>Variable</string>
<key>VariableName</key>
<string>x</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</dict>
</array>
</dict>
</plist>
The value 5 flows into double, and the result flows into triple. You can also use |>? for optional values. If the value is nil, the pipeline short-circuits and the result is nil.
For more details, see Pipelines.
Enums and records give you structured data
Chute adds enums and records for data that Shortcuts represents without custom types.
Enums represent a fixed set of values. Each case can have a backing string value:
enum Color { red = "RED", blue = "BLUE", green = "GREEN" }
const c: Color = .red;Records are named groups of fields, similar to structs:
record Point { x: Number, y: Number }
const p = Point(x: 10, y: 20);Records compile to dictionaries in the Shortcuts output. Each field becomes a key-value pair.
For more details, see Enums and records.
Imports let you split code across files
As your shortcuts grow, you can split code across multiple .chute files. Use export to make declarations available to other files, and import to bring them in.
// In math.chute
export func add(a: Number, b: Number) -> Number {
return a + b;
}// In main.chute
import "./math" as math;
const sum = math.add(3, 4);For more details, see Imports & Modules.
The standard library wraps common Shortcuts actions
Chute includes 390 standard library action declarations in 17 modules. Import a module before calling its actions:
import Scripting;
import Notification;
Scripting.askForInput("What is your name?");
Notification.showAlert("Hello!");<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>WFWorkflowClientVersion</key>
<string>1</string>
<key>WFWorkflowHasOutputFallback</key>
<false/>
<key>WFWorkflowHasShortcutInputVariables</key>
<false/>
<key>WFWorkflowIcon</key>
<dict>
<key>WFWorkflowIconGlyphNumber</key>
<integer>59511</integer>
<key>WFWorkflowIconStartColor</key>
<integer>4274264319</integer>
</dict>
<key>WFWorkflowImportQuestions</key>
<array/>
<key>WFWorkflowInputContentItemClasses</key>
<array/>
<key>WFWorkflowMinimumClientVersion</key>
<integer>900</integer>
<key>WFWorkflowMinimumClientVersionString</key>
<string>900</string>
<key>WFWorkflowName</key>
<string>Untitled Shortcut</string>
<key>WFWorkflowTypes</key>
<array>
<string>NCWidget</string>
<string>WatchKit</string>
</array>
<key>WFWorkflowActions</key>
<array>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.ask</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000000</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFAskActionPrompt</key>
<string>What is your name?</string>
</dict>
</dict>
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.alert</string>
<key>UUID</key>
<string>00000000-0000-0000-0000-000000000001</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFAlertActionMessage</key>
<string>Hello!</string>
</dict>
</dict>
</array>
</dict>
</plist>
The standard library reference lists every module and action. Each declaration defines its parameters, types, defaults, and Shortcuts identifier. The compiler uses that declaration to emit the action and its parameter keys.