louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#125 · main · 16 min 13 s
0Étoiles
0Forks
40Issues
| 1 | import std/html.{type Html} |
| 2 | import std/io |
| 3 | |
| 4 | effect log |
| 5 | { |
| 6 | fn log :: msg: String -> () |
| 7 | } |
| 8 | |
| 9 | pub fn greet :: name: String -> Html / <log> |
| 10 | { |
| 11 | log ("rendering " <> name) |
| 12 | <h1 class="title">Hello, {name}!</h1> |
| 13 | } |
| 14 | |
| 15 | fn with_console_log :: action: fn() -> a / <log, io | e> -> a / <io | e> |
| 16 | { |
| 17 | handle |
| 18 | { |
| 19 | action () |
| 20 | } |
| 21 | with |
| 22 | { log msg -> io.println ("[log] " <> msg) } |
| 23 | } |
| 24 | |
| 25 | pub fn main :: -> () / <io> |
| 26 | { |
| 27 | use <- with_console_log |
| 28 | io.println (html.render (greet "Ada")) |
| 29 | } |
| 30 | //> [log] rendering Ada |
| 31 | //> <h1 class="title">Hello, Ada!</h1> |