navid/haze / c0b95f8eeae4f6db6308cd4c9942340bde71175d389cc031539ebe88ded804fc / samples/baseline_2.4/generic_multi_instantiation.hz

generic_multi_instantiation.hz

← samples/baseline_2.4 · 257 bytes · raw · download

pure fn choose[T](a T, b T, first bool) T
    : post r => r == a || r == b
    => if first {
        a
    } else {
        b
    }

fn main() {
    print(choose(1, 2, false))
    print(choose(true, false, true))
    print(choose("left", "right", false))
}