rcore::diagnostic

This commit is contained in:
AF 2023-05-30 15:07:09 +00:00
parent 8d3593cf2d
commit 8997900157
2 changed files with 19 additions and 16 deletions

View File

@ -3,6 +3,7 @@
//! Allows for more generic behaviour via [`Context`], as opposed to original async-only.
mod addresses;
mod diagnostic;
mod hashing;
mod origin;
mod point;
@ -17,6 +18,7 @@ use std::{error::Error, rc::Rc};
use crate::func::*;
pub use self::addresses::Addresses;
pub use self::diagnostic::Diagnostic;
pub use self::hashing::{Hash, HASH_SIZE, HASH_ZEROS};
pub use self::origin::{OFctr, Origin};
pub use self::point::Point;
@ -28,22 +30,6 @@ pub use self::resolution::{
pub use self::serialization::{Deserializer, DeserializerExt, Serializable, Serializer};
pub use self::slice_deserializer::SliceDeserializer;
/// Basic support for tracing events across the execution.
pub trait Diagnostic<'a, T: Monad<'a>> {
/// Specify that the evaluation happens after a specific event.
fn after<'b, A: 'a>(fa: T::F<A>, event: impl 'b + FnOnce() -> String) -> T::F<A>
where
'a: 'b;
/// Specify that the evaluation happens before a specific event.
fn before<'b, A: 'a>(fa: T::F<A>, event: impl 'b + FnOnce() -> String) -> T::F<A>
where
'a: 'b;
/// Label the evaluation step as a specific named action.
fn wrapped<'b, A: 'a>(fa: T::F<A>, event: impl 'b + FnOnce() -> String) -> T::F<A>
where
'a: 'b;
}
/// Execution context.
pub trait Context<'a>: 'a {
/// Type to provide for [Monad]ic representation of computation, mostly that of resolution ([`Resolution`]).

17
src/rcore/diagnostic.rs Normal file
View File

@ -0,0 +1,17 @@
use crate::func::Monad;
/// Basic support for tracing events across the execution.
pub trait Diagnostic<'a, T: Monad<'a>> {
/// Specify that the evaluation happens after a specific event.
fn after<'b, A: 'a>(fa: T::F<A>, event: impl 'b + FnOnce() -> String) -> T::F<A>
where
'a: 'b;
/// Specify that the evaluation happens before a specific event.
fn before<'b, A: 'a>(fa: T::F<A>, event: impl 'b + FnOnce() -> String) -> T::F<A>
where
'a: 'b;
/// Label the evaluation step as a specific named action.
fn wrapped<'b, A: 'a>(fa: T::F<A>, event: impl 'b + FnOnce() -> String) -> T::F<A>
where
'a: 'b;
}