Skip to content

Conversation

Copy link

Copilot AI commented Oct 17, 2025

This PR adds support for the ~> context operator, which allows using the left-hand context to transform the input on the right. This operator is similar to with statements or binding contexts from functional programming languages.

What's Changed

The ~> operator provides a concise way to access properties within a context without repeating the context variable name. For example:

PainPoint {
  name
  description
  impact: 1..10      // how much this hurts when it happens
  frequency: 1..10   // how often this happens
}

UserStory {
  name
  description
  painPoint
  // The following is equivalent to:
  // priority = painPoint.impact * painPoint.frequency
  priority = painPoint ~> impact * frequency
  functionalRequirements
  mockups
  phases
}

Implementation

  • Syntax highlighting: Added ~> to the operator pattern in sudolang.tmLanguage.json for proper syntax highlighting
  • Documentation: Added a new section in sudolang.sudo.md explaining the context operator with the example from the issue
  • Test coverage: Added usage examples in syntax-test.sudo to demonstrate the operator in action

The operator is positioned in the regex pattern right before the pipe operator |> for consistency with existing operator patterns.

Fixes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>Add ~> operator</issue_title>
<issue_description>The ~> operator means "use the LH context to transform the input on the right." e.g.:

PainPoint {
  name
  description
  impact: 1..10      // how much this hurts when it happens
  frequency: 1..10   // how often this happens
}

UserStory {
  name
  description
  painPoint
  // The following is equivalent to:
  // priority = painPoint.impact * painPoint.frequency
  priority = painPoint ~> impact * frequency
  functionalRequirements
  mockups
  phases
}

Similar to with statements or binding contexts from functional programming languages.</issue_description>

<agent_instructions>Please look carefully at the documentation and syntax-test.sudo to figure out the best way to approach this.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #35


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits October 17, 2025 00:27
Co-authored-by: ericelliott <364727+ericelliott@users.noreply.github.com>
Co-authored-by: ericelliott <364727+ericelliott@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ~> operator for transforming input context Add ~> context operator for implicit context binding Oct 17, 2025
Copilot AI requested a review from ericelliott October 17, 2025 00:30
Copilot finished work on behalf of ericelliott October 17, 2025 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ~> operator

2 participants