blob: 81a7eda8d97c185c1ded3a781ff9a640489e686d [file] [log] [blame]
cue eval disjunctions.cue
cmp stdout expect-stdout-cue
-- frontmatter.toml --
title = "Disjunctions"
description = ""
-- text.md --
Disjunctions, or sum types, define a new type that is one of several things.
In the example, `conn` defines a `protocol` field that must be one of two
values: `"tcp"` or `"udp"`.
It is an error for a concrete `conn`
to define anything else than these two values.
-- disjunctions.cue --
conn: {
address: string
port: int
protocol: "tcp" | "udp"
}
lossy: conn & {
address: "1.2.3.4"
port: 8888
protocol: "udp"
}
-- expect-stdout-cue --
conn: {
address: string
port: int
protocol: "tcp" | "udp"
}
lossy: {
address: "1.2.3.4"
port: 8888
protocol: "udp"
}