// A constructor used as a value is a function of its fields, by position: // its field names are not parameter labels (ADR 0062, issue #320). import std/result type Msg { Peek(reply: Int), Pair(a: Int, b: String) } fn apply :: f: fn(Int) -> Msg x: Int -> Msg { f x } pub fn passed :: -> Msg { apply Peek 1 } pub fn stored :: -> Msg { let f = Peek f 1 } pub fn mapped :: r: Result -> Result { result.map r Peek } pub fn two_fields :: -> Msg { let f = Pair f 1 "one" } // A field name is not a label of the value. pub fn labelled :: -> Msg { let f = Peek f ~reply: 1 //~ ERROR E0204 } // Construction keeps its labelled fields. pub fn constructed :: -> Msg { Pair(b: "two", a: 2) }