import std/io
// `Wire` (ADR 0072) has a dictionary, unlike `Send`: a function or an
// impl with `where Wire` takes one, and every caller passes it,
// derived impls included.
pub type Box { Box(value: a) }
impl Eq> where Eq, Wire
{
fn eq :: x: Box y: Box -> Bool
{
match (x, y) { (Box(a), Box(b)) -> a == b }
}
}
// Its field's `Eq` comes from the impl above, which needs `Wire`.
@derive Eq
pub type Labelled { Labelled(String, Box) }
fn describe :: x: a -> String where Wire, Show
{
show x
}
// Inferred: `where Wire, Show`.
fn twice :: x
{
describe [x, x]
}
pub fn main :: -> () /
{
io.println (show (Labelled("a", Box(1)) == Labelled("a", Box(1))))
io.println (show (Labelled("a", Box(1)) == Labelled("a", Box(2))))
io.println (describe (1, "two"))
io.println (twice True)
}
//> True
//> False
//> (1, two)
//> [True, True]