Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Inspect expanded DSRV with tc-expand

tc-expand shows a DSRV program after expansion. It loads the root model and its filesystem or embedded modules, resolves imports, and inlines named functions. The report lists the activated modules, stream declarations, type aliases, and expanded equations. With --check-mode, it also type-checks the program and shows resolved stream annotations. The tool does not evaluate the program.

Example

This example imports the embedded std::option module and calls its functions:

use experimental::{modules, generics, tagged_unions}
use std::option

in reading: option::Option<Int>
out present: Bool = std::option::is_some(reading)
out absent: Bool = std::option::is_none(reading)
out value: Int = std::option::unwrap_or(reading, 7)
out sample: option::Option<Int> = Some(7)
out empty: option::Option<Int> = None

From the repository root, run:

cargo run --bin tc-expand -- --check-mode strict examples/std_option.dsrv

The report begins:

# tc-expand inspection (checked (strict)); non-standalone source report
# language: Full DSRV, experiments tagged_unions, generics, modules
# activated modules:
#   std::option [embedded catalogue]

in reading: Union<None, Some: Int>
out present: Bool
present = (\option -> matches(option, Some(_))(reading): Bool)

The command exits 0 on success. Omit --check-mode strict for an expanded, unchecked view, or use --check-mode gradual for gradual checking. Errors and warnings go to stderr; a model or checking failure exits 1 without a report on stdout.