Skip to content

Add custom literals example - #299

Open
ageron wants to merge 5 commits into
roc-lang:mainfrom
ageron:add-custom-literals-example
Open

ageron wants to merge 5 commits into
roc-lang:mainfrom
ageron:add-custom-literals-example

Conversation

@ageron

@ageron ageron commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds an example showing how to define custom literals using:

  • from_numeral
  • from_quote
  • from_interpolation

The example shows the two syntaxes:

temp1 : Celsius
temp1 = 21

temp2 = 21.Celsius

It also shows:

  • How these custom literals interact with (and differ from) functions like from_str.
  • How to run any pure function at runtime using Ok(validated_value) = some_pure_function(...).

Fixes roc-lang/roc#10872

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 examples to from_quote and from_interpolation docs

1 participant