Add LocalDispatch example demonstrating arrow operator#252
Open
codegod100 wants to merge 1 commit intoroc-lang:mainfrom
Open
Add LocalDispatch example demonstrating arrow operator#252codegod100 wants to merge 1 commit intoroc-lang:mainfrom
codegod100 wants to merge 1 commit intoroc-lang:mainfrom
Conversation
- Show the -> operator for local dispatch (replaces |> pizza operator) - Demonstrate chaining: value->func1->func2->func3 - Compare with method syntax and traditional function calls - Include README with usage guide Note: This example uses new Roc syntax and will work once the examples repo is updated to new Roc.
Anton-4
requested changes
Dec 31, 2025
Collaborator
Anton-4
left a comment
There was a problem hiding this comment.
Thanks @codegod100, this looks great :)
I'm just going to set this to request changes to make sure we do this before merging:
- Move this to a single file notebook format that can execute code and run "invisible" tests. Support for this is not yet implemented in the current Roc CLI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new example demonstrating the
->arrow operator for local dispatch.Overview
The arrow operator
->replaces the pizza operator|>from old Roc. It passes the left-hand value as the first argument to a function in local scope.What's Demonstrated
5->double3->double->add_ten->square.method()) with local dispatch (->func)Example
Note
This example uses new Roc syntax and will work once the examples repo is updated to new Roc.