use serde::{Deserialize, Serialize};
use std::collections::BTreeSet;
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub enum Type {
Number,
Float,
Decimal,
String,
Bool,
Bytes,
List(Box<Type>),
Map(Box<Type>, Box<Type>),
Option(Box<Type>),
Result(Box<Type>, Box<Type>),
Named(String),
Cell(Box<Type>),
Fn {
params: Vec<Type>,
ret: Box<Type>,
effects: BTreeSet<Effect>,
},
Var(String),
Never,
}
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Serialize, Deserialize)]
pub enum Confidence {
External,
Structural,
Validated,
Persisted,
}
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Serialize, Deserialize)]
pub enum Effect {
Net,
Disk,
Db,
Mut,
Time,
Rand,
Log,
Live,
Resp,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn confidence_total_order_matches_section_4() {
use Confidence::*;
assert!(External < Structural);
assert!(Structural < Validated);
assert!(Validated < Persisted);
assert_eq!(std::cmp::min(Persisted, External), External);
assert_eq!(std::cmp::min(Validated, Structural), Structural);
}
}