diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-06 23:37:05 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-06 23:37:05 -0400 |
| commit | 1a196aa8f724971e531487f9cdd541f7957cfd92 (patch) | |
| tree | 52a36701065ab0e3f7012765c909c3b2a3fd2e49 /docs/langs.md | |
| parent | 4a3db447ce820617a72bdd9fc6217c84c3799bea (diff) | |
Update syntax in docs
Diffstat (limited to 'docs/langs.md')
| -rw-r--r-- | docs/langs.md | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/docs/langs.md b/docs/langs.md index aec9cfa9..8f440932 100644 --- a/docs/langs.md +++ b/docs/langs.md @@ -9,8 +9,8 @@ values and give type checking errors if you attempt to use one type of string where a different type of string is needed. ```tomo -lang HTML: - convert(t:Text -> HTML): +lang HTML + convert(t:Text -> HTML) t = t.translate({ "&" = "&", "<" = "<", @@ -20,7 +20,7 @@ lang HTML: }) return HTML.from_text(t) - func paragraph(content:HTML -> HTML): + func paragraph(content:HTML -> HTML) return $HTML"<p>$content</p>" ``` @@ -73,11 +73,11 @@ instead of building a global function called `execute()` that takes a `ShellScript` argument, you could instead build something like this: ```tomo -lang Sh: - convert(text:Text -> Sh): +lang Sh + convert(text:Text -> Sh) return Sh.from_text("'" ++ text.replace("'", "''") ++ "'") - func execute(sh:Sh -> Text): + func execute(sh:Sh -> Text) ... dir := ask("List which dir? ") @@ -92,14 +92,14 @@ keyword. Conversions can be defined either inside of the language's block, another type's block or at the top level. ```tomo -lang Sh: - convert(text:Text -> Sh): +lang Sh + convert(text:Text -> Sh) return Sh.from_text("'" ++ text.replace("'", "''") ++ "'") -struct Foo(x,y:Int): - convert(f:Foo -> Sh): +struct Foo(x,y:Int) + convert(f:Foo -> Sh) return Sh.from_text("$(f.x),$(f.y)") -convert(texts:[Text] -> Sh): +convert(texts:[Text] -> Sh) return $Sh" ".join([Sh(t) for t in texts]) ``` |
