refactor: type
This commit is contained in:
43
src/ty/public/mod.rs
Normal file
43
src/ty/public/mod.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use std::fmt::{Debug, Formatter, Result as FmtResult};
|
||||
|
||||
use derive_more::{Constructor, IsVariant, Unwrap};
|
||||
use rpds::{HashTrieMapSync, VectorSync};
|
||||
|
||||
use super::common::*;
|
||||
|
||||
mod cnst;
|
||||
|
||||
pub use cnst::Const;
|
||||
|
||||
#[derive(Constructor, Clone, PartialEq)]
|
||||
pub struct AttrSet {
|
||||
data: HashTrieMapSync<Symbol, Value>,
|
||||
}
|
||||
|
||||
impl Debug for AttrSet {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||
write!(f, "{{ ")?;
|
||||
for (k, v) in self.data.iter() {
|
||||
write!(f, "{k:?} = {v:?}; ")?;
|
||||
}
|
||||
write!(f, "}}")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Constructor, Clone, Debug, PartialEq)]
|
||||
pub struct List {
|
||||
data: VectorSync<Value>,
|
||||
}
|
||||
|
||||
|
||||
#[derive(IsVariant, Unwrap, Clone, Debug, PartialEq)]
|
||||
pub enum Value {
|
||||
Const(Const),
|
||||
AttrSet(AttrSet),
|
||||
List(List),
|
||||
Catchable(Catchable),
|
||||
Thunk,
|
||||
Func,
|
||||
PrimOp,
|
||||
PartialPrimOp,
|
||||
}
|
||||
Reference in New Issue
Block a user