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.

73 lignes · 1475 octetsBrut · Historique
1import std/html.{type Element, type Html}
2
3// A literal is an `Element<msg>` for any `msg`.
4fn para ::
5{
6 <p>text</p>
7}
8//~ TYPE para: fn() -> Element<a>
9
10fn items :: xs: List<Html> -> Html
11{
12 <ul>{xs}</ul>
13}
14
15// Other children are shown, so they need `Show` (ADR 0034).
16pub fn shown_child :: n: Int -> Html
17{
18 <p>{n}</p>
19}
20
21pub fn bad_child :: f: fn(Int) -> Int -> Html
22{
23 <p>{f}</p> //~ ERROR E0401 does not implement `Show`
24}
25
26pub fn bad_attr :: xs: List<Int> -> Html
27{
28 <p class={xs}>x</p>
29 //~^ ERROR E0602 must be a String, Int, Bool or Option<String>
30}
31
32pub fn events :: -> Html
33{
34 <button onclick="go()">x</button>
35 //~^ ERROR E0603 reserved for the client target
36}
37
38fn card :: title: String children: List<Element<msg>> -> Element<msg>
39{
40 <section><h2>{title}</h2>{children}</section>
41}
42
43pub fn uses_card :: -> Html
44{
45 <Card title="t"><p>body</p></Card>
46}
47
48pub fn flag_on_component :: -> Html
49{
50 <Card title><p>x</p></Card> //~ ERROR E0604 needs a value
51}
52
53// `Option<String>`: `None` leaves the attribute out (ADR 0057).
54pub fn option_attr :: value: Option<String> -> Html
55{
56 <input value={value}/>
57}
58
59pub fn bad_option_attr :: value: Option<Int> -> Html
60{
61 <input value={value}/> //~ ERROR E0202 expected `String`, found `Int`
62}
63
64pub fn missing_component :: -> Html
65{
66 <Panel/> //~ ERROR E0101 no value named `panel`
67}
68
69pub fn wrong_component_arg :: -> Html
70{
71 <Card title={42}><p>x</p></Card>
72 //~^ ERROR E0202 expected `String`, found `Int`
73}