Skip to main content

bynk_check/
builtin_names.rs

1//! Centralised string literals for the language's built-in vocabulary (refactor
2//! track item 8, v0.29.11). Built-in type/method names were compared as bare
3//! string literals scattered across the checker, emitter, and project modules;
4//! a typo was a silent never-match. One edit point per name now.
5
6/// Built-in type names (as they appear in source / qualified positions).
7pub mod types {
8    pub const JSON: &str = "Json";
9    pub const LIST: &str = "List";
10    pub const MAP: &str = "Map";
11    pub const INT: &str = "Int";
12    pub const FLOAT: &str = "Float";
13    pub const DURATION: &str = "Duration";
14    pub const INSTANT: &str = "Instant";
15    pub const BYTES: &str = "Bytes";
16    pub const HTTP_RESULT: &str = "HttpResult";
17    pub const QUEUE_RESULT: &str = "QueueResult";
18    pub const STREAM: &str = "Stream";
19    /// The compiler-known entry record a map's `.entries` query yields
20    /// (v0.158, ADR 0184). A nominal generic record `{ key: K, value: V }`
21    /// — bynk stays nominal (ADR 0120), so a map entry is a named record, not
22    /// an anonymous pair. Non-boundary like every generic-record instantiation
23    /// (ADR 0183): project it through `.map` into a named type before a
24    /// terminal that leaves the pipeline.
25    pub const MAP_ENTRY: &str = "MapEntry";
26}
27
28/// The `.entries` / `.keys` / `.values` accessors a `store Map[K, V]` field
29/// exposes as lazy queries (v0.158, ADR 0184), and the two fields the
30/// `MapEntry` record carries.
31pub mod map_query {
32    /// `map.entries : Query[MapEntry[K, V]]`.
33    pub const ENTRIES: &str = "entries";
34    /// `map.keys : Query[K]`.
35    pub const KEYS: &str = "keys";
36    /// `map.values : Query[V]`.
37    pub const VALUES: &str = "values";
38    /// `MapEntry.key : K`.
39    pub const KEY: &str = "key";
40    /// `MapEntry.value : V`.
41    pub const VALUE: &str = "value";
42}
43
44/// Privileged built-in member names — constructors (`of`/`unsafe`), the refined
45/// raw accessor (`raw`), and the effect terminals (`foldEff`/`forEach`).
46pub mod methods {
47    pub const OF: &str = "of";
48    pub const UNSAFE: &str = "unsafe";
49    pub const RAW: &str = "raw";
50    pub const FOLD_EFF: &str = "foldEff";
51    pub const FOR_EACH: &str = "forEach";
52    pub const PAR_TRAVERSE: &str = "parTraverse";
53    pub const TRAVERSE_ALL: &str = "traverseAll";
54    pub const PAR_TRAVERSE_ALL: &str = "parTraverseAll";
55    pub const TRAVERSE_TRY: &str = "traverseTry";
56    pub const PAR_TRAVERSE_TRY: &str = "parTraverseTry";
57}
58
59#[cfg(test)]
60mod tests {
61    use super::*;
62
63    #[test]
64    fn constants_hold_expected_values() {
65        assert_eq!(types::JSON, "Json");
66        assert_eq!(types::HTTP_RESULT, "HttpResult");
67        assert_eq!(methods::OF, "of");
68        assert_eq!(methods::FOLD_EFF, "foldEff");
69        assert_eq!(methods::FOR_EACH, "forEach");
70        assert_eq!(methods::PAR_TRAVERSE, "parTraverse");
71        assert_eq!(methods::TRAVERSE_ALL, "traverseAll");
72        assert_eq!(methods::PAR_TRAVERSE_ALL, "parTraverseAll");
73        assert_eq!(methods::TRAVERSE_TRY, "traverseTry");
74        assert_eq!(methods::PAR_TRAVERSE_TRY, "parTraverseTry");
75    }
76}