blob: 99bb955003049c0b08dc7742887067e3ed3b0e4b [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"
}