// Opaque types (ADR 0033): what a module may declare. Their use from other // modules (E0117) is tested in crates/louise_types/tests/opaque.rs. /// Inside its module, an opaque type is like any other. @derive Eq Show pub opaque type Count { Count(value: Int) } pub fn count :: n: Int -> Option { if n < 0 { None } else { Some(Count(n)) } } pub fn value :: c: Count -> Int { c.value } pub fn add :: a: Count b: Count -> Count { match a { Count(n) -> Count(..b, value: n + b.value) } } opaque type Secret { Secret(Int) } //~ ERROR E0118 already private pub opaque type Meters = Int //~ ERROR E0118 an alias pub opaque type Handle //~ ERROR E0118 abstract type @derive Default pub opaque type Total //~ ERROR E0408 opaque type `Total` { Total(Int) }