// String interpolation (ADR 0034): `{e}` is `show(e)`, `{e:?}` is
// `debug(e)`, and the parts are joined once.
import std/html.{type Html}
import std/io
import std/list
@derive Show Debug
pub type Point { Point(x: Int, y: Int) }
/// HTML text holes take any `Show` value, shown then escaped.
fn cell :: p: Point n: Int -> Html
{
{n} is {p} in {""} |
}
fn shown :: xs: List -> String
{
"{list.length xs} items, reversed {list.reverse xs:?}"
}
pub fn main :: -> () /
{
let name = "ada"
let p = Point(1, 2)
io.println "hello {name}, you are {36 + 1}"
io.println "{p} and {p:?} and {name:?}"
io.println (shown [3, 4])
io.println "braces: \{ and \}, {if True { "nested" } else { "no" }}"
io.println "{1.5}{-2}{True}{()}{(1, "a")}"
io.println ""
io.println "\u{1F600} {name}"
io.println (html.render (cell p 3))
}
//> hello ada, you are 37
//> Point(1, 2) and Point { x: 1, y: 2 } and "ada"
//> 2 items, reversed [4, 3]
//> braces: { and }, nested
//> 1.5-2True()(1, a)
//>
//> 😀 ada
//> 3 is Point(1, 2) in <b> |