tobogganSe connecter

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.

31 lignes · 532 octetsBrut · Historique
1import std/html.{type Html}
2import std/io
3
4effect log
5{
6 fn log :: msg: String -> ()
7}
8
9pub fn greet :: name: String -> Html / <log>
10{
11 log ("rendering " <> name)
12 <h1 class="title">Hello, {name}!</h1>
13}
14
15fn 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
25pub 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>