1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::{
api::{generic::A, Generic, OpaqueRef},
thread::Thread,
value::ValueRepr,
ExternModule, Result,
};
fn trace(a: Generic<A>) {
println!("{:?}", a);
}
fn show(a: Generic<A>) -> String {
format!("{:?}", a)
}
fn tag(a: OpaqueRef<A>) -> Option<String> {
unsafe {
match a.get_value().get_repr() {
ValueRepr::Data(data) => data.poly_tag().map(|s| s.to_string()),
_ => None,
}
}
}
mod std {
pub use crate::debug;
}
pub fn load(vm: &Thread) -> Result<ExternModule> {
use self::std;
ExternModule::new(
vm,
record! {
trace => primitive!(1, std::debug::trace),
show => primitive!(1, std::debug::show),
tag => primitive!(1, std::debug::tag)
},
)
}