...
1
2-- frontmatter.toml --
3title = "Types are values"
4description = ""
5
6-- text.md --
7CUE merges the concepts of values and types.
8Below is a demonstration of this concept,
9showing respectively
10some data, a possible schema for this data,
11and something in between: a typical CUE constraint.
12
13{{< blocks/sidebyside >}}
14<div class="col">
15<i>Data</i>
16{{< highlight go >}}
17moscow: {
18 name: "Moscow"
19 pop: 11.92M
20 capital: true
21}
22{{< /highlight >}}
23</div>
24
25<div class="col">
26<i>Schema</i>
27{{< highlight go >}}
28municipality: {
29 name: string
30 pop: int
31 capital: bool
32}
33{{< /highlight >}}
34</div>
35
36<div class="col">
37<i>CUE</i>
38{{< highlight go >}}
39largeCapital: {
40 name: string
41 pop: >5M
42 capital: true
43}
44{{< /highlight >}}
45</div>
46{{< /blocks/sidebyside >}}
47
48In general, in CUE one starts with a broad definition of a schema,
49describing all possible instances,
50and then narrows down these definitions for particular use cases
51until a concrete data instance remains.
View as plain text