Skip to content

Commit

Permalink
WIP error bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
AZWN committed Oct 30, 2024
1 parent 558c44b commit 08b8b38
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions scopegraphs/src/containers/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ where
}
}

impl<'sg: 'rslv, 'rslv, LABEL: 'sg + Eq, DATA: 'sg + Eq, E: 'rslv>
/* impl<'sg: 'rslv, 'rslv, LABEL: 'sg + Eq, DATA: 'sg + Eq, E: 'rslv>
Injectable<'sg, 'rslv, LABEL, DATA, Result<bool, E>> for Result<Env<'sg, LABEL, DATA>, E>
where
ResolvedPath<'sg, LABEL, DATA>: Hash + Clone,
Expand All @@ -143,7 +143,7 @@ where
fn inject_if(data_ok: Result<bool, E>, path: ResolvedPath<'sg, LABEL, DATA>) -> Self {
data_ok.map(|ok| if ok { Env::single(path) } else { Env::empty() })
}
}
} */

impl<'sg: 'rslv, 'rslv, LABEL: 'sg + Eq, DATA: 'sg + Eq, RE, UE>
Injectable<'sg, 'rslv, LABEL, DATA, Result<bool, RE>>
Expand Down
1 change: 1 addition & 0 deletions scopegraphs/src/containers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! by [`Completeness`](crate::completeness::Completeness) implementations.
/// Union of errors during resolution (i.e., delays) and error during predicate evaluation.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub enum ResolveOrUserError<RE, UE> {
/// Resolution error.
Resolve(RE),
Expand Down
13 changes: 7 additions & 6 deletions scopegraphs/src/containers/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub trait ScopeContainer<'sg, 'rslv, LABEL: Debug + 'sg, DATA: 'sg>: Debug {
/// - [Result] of scope containers, and
/// - [FutureWrapper] of scope containers.
/// ```
/// # use scopegraphs::containers::ScopeContainerWf;
/// # use scopegraphs::containers::{ResolveOrUserError,ScopeContainerWf};
/// # use scopegraphs::future_wrapper::FutureWrapper;
/// # use scopegraphs::Scope;
/// # use std::fmt::Debug;
Expand All @@ -44,10 +44,11 @@ pub trait ScopeContainer<'sg, 'rslv, LABEL: Debug + 'sg, DATA: 'sg>: Debug {
/// test::<'_, '_, LABEL, DATA, bool>(vec);
/// # }
///
/// # fn result<'sg, 'rslv, LABEL: LBound<'sg>, DATA: DBound<'sg>, E: Debug + Clone>() {
/// let result: Result<Vec<Scope>, E> = todo!();
/// # fn result<'sg, 'rslv, LABEL: LBound<'sg>, DATA: DBound<'sg>, RE: Debug + Clone + 'rslv, UE: Debug + Clone + 'rslv>() {
/// let result: Result<Vec<Scope>, RE> = todo!();
/// test::<'_, '_, LABEL, DATA, bool>(result);
/// test::<'_, '_, LABEL, DATA, Result<bool, E>>(result);
/// let result_or_err: Result<Vec<Scope>, ResolveOrUserError<RE, UE>> = todo!();
/// test::<'_, '_, LABEL, DATA, Result<bool, UE>>(result_or_err);
/// # }
///
/// # fn future<'sg, 'rslv, LABEL: LBound<'sg>, DATA: DBound<'sg>>() {
Expand All @@ -70,13 +71,13 @@ pub trait ScopeContainer<'sg, 'rslv, LABEL: Debug + 'sg, DATA: 'sg>: Debug {
/// ```
///
/// ```no_run
/// # use scopegraphs::containers::ScopeContainerWf;
/// # use scopegraphs::containers::{ResolveOrUserError, ScopeContainerWf};
/// # use scopegraphs::Scope;
/// # use std::fmt::Debug;
/// # use std::hash::Hash;
///
/// test::<'_, '_, (), (), bool>(Result::<_, ()>::Ok(Vec::<Scope>::new()));
/// test::<'_, '_, (), (), Result<bool, ()>>(Result::<_, ()>::Ok(Vec::<Scope>::new()));
/// test::<'_, '_, (), (), Result<bool, ()>>(Result::<_, ResolveOrUserError<(), ()>>::Ok(Vec::<Scope>::new()));
///
/// fn test<'sg, 'rslv, LABEL: Clone + Hash + Eq + Debug + 'sg, DATA: Hash + Eq + 'sg, DWFO>(
/// cont: impl ScopeContainerWf<'sg, 'rslv, LABEL, DATA, DWFO, DWFO>
Expand Down
20 changes: 8 additions & 12 deletions scopegraphs/src/resolve/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,14 @@ where
#[cfg(test)]
mod tests {

use std::convert::Infallible;

use scopegraphs_macros::label_order;

use crate::{
add_scope,
completeness::{
add_scope, completeness::{
Delay, ExplicitClose, FutureCompleteness, ImplicitClose, UncheckedCompleteness,
},
future_wrapper::FutureWrapper,
query_regex,
resolve::{Resolve, ResolvedPath},
storage::Storage,
Label, ScopeGraph,
}, containers::ResolveOrUserError, future_wrapper::FutureWrapper, query_regex, resolve::{Resolve, ResolvedPath}, storage::Storage, Label, ScopeGraph
};

#[derive(Label, Hash, PartialEq, Eq, Debug, Clone, Copy)]
Expand Down Expand Up @@ -392,7 +388,7 @@ mod tests {
|data: &Self| data.matches(n)
}

fn matcher_res(n: &'a str) -> impl (for<'b> Fn(&'b Self) -> Result<bool, Delay<Lbl>>) {
fn matcher_res(n: &'a str) -> impl (for<'b> Fn(&'b Self) -> Result<bool, Infallible>) {
|data: &Self| Ok(data.matches(n))
}

Expand Down Expand Up @@ -658,7 +654,7 @@ mod tests {
// todo!("assert the correct edges are closed!")
}

#[test]
/* #[test]
fn test_label_order_complex_explicit_close() {
let storage = Storage::new();
let scope_graph: ScopeGraph<Lbl, TData, ExplicitClose<Lbl>> =
Expand Down Expand Up @@ -692,7 +688,7 @@ mod tests {
let_lex.close();
let_def.close();
let env = scope_graph
let env: Result<_, ResolveOrUserError<_, Infallible>> = scope_graph
.query()
.with_path_wellformedness(query_regex!(Lbl: Lex* Imp? Def))
.with_data_wellformedness(TData::matcher_res("x"))
Expand All @@ -707,7 +703,7 @@ mod tests {
assert!(matches!(path.data(), &Data { name: "x", data: 2 }));
// todo!("assert the correct edges are closed!")
}
}*/

#[test]
fn test_caching() {
Expand Down

0 comments on commit 08b8b38

Please sign in to comment.