Significantly extended stdlib

This commit is contained in:
2026-01-27 20:53:45 +01:00
parent 66e5a71032
commit 534f08b45c
42 changed files with 635 additions and 211 deletions

View File

@@ -8,7 +8,8 @@ use orchid_base::name::{NameLike, Sym};
use orchid_extension::atom::{Atomic, Supports, TAtom};
use orchid_extension::atom_owned::{OwnedAtom, OwnedVariant, own};
use orchid_extension::expr::{Expr, ExprHandle};
use orchid_extension::system::dep_req;
use orchid_extension::gen_expr::new_atom;
use orchid_extension::system::sys_req;
use orchid_extension::tree::{GenMember, fun, prefix};
use crate::std::std_system::StdReq;
@@ -43,7 +44,7 @@ impl Request for CreateSymAtom {
pub async fn sym_expr(sym: Sym) -> Expr {
Expr::from_handle(ExprHandle::deserialize(
dep_req::<StdSystem, _>(CreateSymAtom(sym.to_api())).await,
sys_req::<StdSystem, _>(CreateSymAtom(sym.to_api())).await,
))
}
@@ -51,7 +52,7 @@ pub async fn gen_sym_lib() -> Vec<GenMember> {
prefix("std::refl::sym", [
fun(true, "from_str", async move |str: TAtom<IntStrAtom>| {
match Sym::parse(&es(*str).await).await {
Ok(sym) => Ok(SymAtom(sym)),
Ok(sym) => Ok(new_atom(SymAtom(sym))),
Err(_) => Err(mk_errv(
is("Cannot parse sym from empty string").await,
"Empty string passed to std::refl::sym::from_str",
@@ -60,7 +61,7 @@ pub async fn gen_sym_lib() -> Vec<GenMember> {
}
}),
fun(true, "to_tpl", async move |sym: TAtom<SymAtom>| {
HomoTpl(own(&sym).await.0.segs().map(IntStrAtom).collect())
HomoTpl(own(&sym).await.0.segs().map(|seg| new_atom(IntStrAtom(seg))).collect())
}),
])
}