展示HN:Sigil – 在类型层面跟踪数据信任
Sigil是一种编程语言,其类型系统跟踪数据的来源。
外部数据标记为`~`(已报告)。经过验证的数据标记为`?`(不确定)。计算值标记为`!`(已知)。类型检查器强制执行这些边界——未报告的数据在没有明确验证的情况下无法满足已知要求。
```rust
fn process(input~: str) -> Result! {
let validated? = input |validate!{ parse_int(_) }
let result! = validated * 2 // OK: 计算结果是已知的
result
}
```
这可以在编译时捕获注入漏洞,并使函数签名中的信任边界变得明确。
其他特性:
- 用于管道的语素操作符:`data |τ{_ * 2} |φ{_ > 10} |Σ`
- 类似Rust的所有权和借用
- 自托管编译器(233/233测试通过)
- 解释器、即时编译(JIT)和LLVM后端
使用Rust编写。许可证为MIT/Apache-2.0。
[GitHub链接](https://github.com/Daemoniorum-LLC/sigil-lang)
查看原文
Sigil is a programming language where the type system tracks data provenance.<p><pre><code> External data is marked `~` (reported). Validated data becomes `?` (uncertain).
Computed values are `!` (known). The type checker enforces these boundaries -
reported data can't satisfy a known requirement without explicit validation.
fn process(input~: str) -> Result! {
let validated? = input |validate!{ parse_int(_) }
let result! = validated * 2 // OK: computation produces known
result
}
This catches injection vulnerabilities at compile time and makes trust
boundaries explicit in function signatures.
Other features:
- Morpheme operators for pipelines: `data |τ{_ * 2} |φ{_ > 10} |Σ`
- Rust-like ownership and borrowing
- Self-hosting compiler (233/233 tests passing)
- Interpreter, JIT, and LLVM backends
Written in Rust. MIT/Apache-2.0.
https://github.com/Daemoniorum-LLC/sigil-lang</code></pre>