record { x : Int; y : String }Record([
RecordField("x", Fixnum(...)),
RecordField("y", StringLit(...)),
])///|
test {
let r : Repr = @repr.Repr::record({
"x": Repr::int(1),
"y": Repr::string("hi"),
})
match r {
Record([RecordField("x", Fixnum("1")), RecordField("y", StringLit("hi"))]) =>
()
_ => fail("unexpected Repr shape for record {x: Int; y: String}")
}
}///|
test {
let t : Repr = Repr::tuple([Repr::int(1), Repr::string("x")])
match t {
Tuple([Fixnum("1"), StringLit("x")]) => ()
_ => fail("unexpected Repr shape for tuple (Int, String)")
}
}///|
test {
let r : Repr = Repr::ctor("A", [
(Some("x"), Repr::int(1)),
(Some("y"), Repr::string("hi")),
])
match r {
Enum(
"A",
[EnumLabeledArg("x", Fixnum("1")), EnumLabeledArg("y", StringLit("hi"))]
) => ()
_ => fail("unexpected Repr shape for labeled ctor A(x=Int, y=String)")
}
}pub enum Repr {
UnitLit
Fixnum(String)
DoubleLit(Double)
FloatLit(Float)
BoolLit(Bool)
CharLit(Char)
StringLit(String)
Tuple(Array[Repr])
Array(Array[Repr])
Record(Array[Repr])
Enum(String, Array[Repr])
Map(Array[Repr])
RecordField(String, Repr)
EnumLabeledArg(String, Repr)
Opaque(String, Array[Repr])
Literal(String)
MapEntry(Repr, Repr)
Omitted
}