MCPcopy Create free account
hub / github.com/argumentcomputer/ix / try_string_lit_expansion

Method try_string_lit_expansion

crates/kernel/src/def_eq.rs:1003–1014  ·  view source on GitHub ↗

String literal expansion (C++ kernel: try_string_lit_expansion_core). When `t` is a string literal, expand it to constructor form via `str_lit_to_constructor` (String.ofList [Char.ofNat c₁, ...]), WHNF the result so String.ofList + Char.ofNat delta-unfold to the canonical `String.ofByteArray ...` form, then compare with `s`.

(
    &mut self,
    t: &KExpr<M>,
    s: &KExpr<M>,
  )

Source from the content-addressed store, hash-verified

1001 /// Def-eq for nat-like values: handles mixed literal/constructor comparison.
1002 /// Fast-path: two Nat literals are compared directly by value (O(1) instead of
1003 /// O(n) recursion depth that would blow the def_eq_depth limit).
1004 fn is_def_eq_nat(
1005 &mut self,
1006 a: &KExpr<M>,
1007 b: &KExpr<M>,
1008 ) -> Result<bool, TcError<M>> {
1009 // Fast path: both literals — compare by value directly
1010 if let (ExprData::Nat(va, _, _), ExprData::Nat(vb, _, _)) =
1011 (a.data(), b.data())
1012 {
1013 return Ok(va == vb);
1014 }
1015 if self.is_nat_zero(a) && self.is_nat_zero(b) {
1016 return Ok(true);
1017 }

Callers 2

is_def_eq_innerMethod · 0.80
is_def_eq_whnfMethod · 0.80

Calls 4

dataMethod · 0.45
cloneMethod · 0.45
is_def_eqMethod · 0.45

Tested by

no test coverage detected