Skip to content

SQRT Basic Types

SQRT in Python Code Block

Code blocks in this tutorial are Python literals containing actual SQRT code for ease of testing.

SQRT supports type domains that constrain what values are valid. These are used in predicates to check if values match expected patterns. Below we cover the basic types supported in SQRT.

Download Tutorial Script

Boolean Domains

Boolean domains constrain values to true or false:

# Boolean domains constrain values to true or false
bool_examples = r"""
let BoolTrue = bool true;
let BoolFalse = bool false;
"""

Integer Domains

Integer domains support exact values and ranges:

# Integer domains support exact values and ranges
int_examples = r"""
// Exact value
let ExactInt = int 42;

// Inclusive range: 1 <= x <= 100
let IntRange = int 1..100;

// Exclusive range: 0 < x < 100
let IntExclusive = int 0<..<100;

// Half-open ranges
let IntExcludeLeft = int 0<..10;   // 0 < x <= 10
let IntExcludeRight = int 0..<10;  // 0 <= x < 10

// Open-ended ranges
let IntFrom = int 10..;   // x >= 10
let IntTo = int ..50;     // x <= 50
"""
Syntax Meaning
int 42 Exactly 42
int 1..100 1 ≤ x ≤ 100 (inclusive)
int 0<..<100 0 < x < 100 (exclusive)
int 0<..10 0 < x ≤ 10
int 0..<10 0 ≤ x < 10
int 10.. x ≥ 10
int ..50 x ≤ 50

Float Domains

Float domains work like integers but with decimal values:

# Float domains work like integers but with decimal values
float_examples = r"""
let ExactFloat = float 3.14;
let FloatRange = float 0.0..1.0;
let FloatToExclusive = float ..<3.14;
"""

String Domains

String domains support three matching modes:

# String domains: exact match, regex, or wildcard patterns
str_examples = r"""
// Exact string match
let ExactStr = str "hello world";

// Regex pattern (r"..." prefix)
let EmailPattern = str matching r"^[a-z]+@example\\.com$";

// Wildcard pattern (w"..." prefix, uses * and ?)
let TxtFiles = str like w"*.txt";

// String with length constraint
let ShortStr = str matching r".*" length 1..20;
"""
Syntax Mode Description
str "hello" Exact Matches exactly "hello"
str matching r"..." Regex Matches the regex pattern
str like w"*.txt" Wildcard Uses * and ? patterns

String domains can also include length constraints: str matching r".*" length 1..100

Datetime Domains

Datetime literals use the d"..." prefix:

# Datetime domains (d"..." prefix for datetime literals)
datetime_examples = r"""
// Exact datetime
let ExactDate = datetime d"2023-10-01T00:00:00Z";

// Datetime range (inclusive)
let DateRange = datetime d"2023-09-01T00:00:00Z"..d"2023-10-01T00:00:00Z";

// Epoch timestamp
let EpochZero = datetime 0;
"""

Datetime values support:

  • ISO 8601 format: d"2023-10-01T00:00:00Z"
  • Epoch timestamps: datetime 0
  • Ranges: d"2023-01-01T00:00:00Z"..d"2023-12-31T23:59:59Z"