
louise
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#1201 · main · 9 min 57 s
1Étoiles
0Forks
0Issues
| 1 | import std/html.{type Element, type Html} |
| 2 | |
| 3 | // A literal is an `Element<msg>` for any `msg`. |
| 4 | fn para :: |
| 5 | { |
| 6 | <p>text</p> |
| 7 | } |
| 8 | //~ TYPE para: fn() -> Element<a> |
| 9 | |
| 10 | fn items :: xs: List<Html> -> Html |
| 11 | { |
| 12 | <ul>{xs}</ul> |
| 13 | } |
| 14 | |
| 15 | // Other children are shown, so they need `Show` (ADR 0034). |
| 16 | pub fn shown_child :: n: Int -> Html |
| 17 | { |
| 18 | <p>{n}</p> |
| 19 | } |
| 20 | |
| 21 | pub fn bad_child :: f: fn(Int) -> Int -> Html |
| 22 | { |
| 23 | <p>{f}</p> //~ ERROR E0401 does not implement `Show` |
| 24 | } |
| 25 | |
| 26 | pub 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 | |
| 32 | pub fn events :: -> Html |
| 33 | { |
| 34 | <button onclick="go()">x</button> |
| 35 | //~^ ERROR E0603 reserved for the client target |
| 36 | } |
| 37 | |
| 38 | fn card :: title: String children: List<Element<msg>> -> Element<msg> |
| 39 | { |
| 40 | <section><h2>{title}</h2>{children}</section> |
| 41 | } |
| 42 | |
| 43 | pub fn uses_card :: -> Html |
| 44 | { |
| 45 | <Card title="t"><p>body</p></Card> |
| 46 | } |
| 47 | |
| 48 | pub 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). |
| 54 | pub fn option_attr :: value: Option<String> -> Html |
| 55 | { |
| 56 | <input value={value}/> |
| 57 | } |
| 58 | |
| 59 | pub fn bad_option_attr :: value: Option<Int> -> Html |
| 60 | { |
| 61 | <input value={value}/> //~ ERROR E0202 expected `String`, found `Int` |
| 62 | } |
| 63 | |
| 64 | pub fn missing_component :: -> Html |
| 65 | { |
| 66 | <Panel/> //~ ERROR E0101 no value named `panel` |
| 67 | } |
| 68 | |
| 69 | pub fn wrong_component_arg :: -> Html |
| 70 | { |
| 71 | <Card title={42}><p>x</p></Card> |
| 72 | //~^ ERROR E0202 expected `String`, found `Int` |
| 73 | } |