From 74c8eaaf5c9e9c1639b9fe4fb5c4082607698d25 Mon Sep 17 00:00:00 2001 From: timofey Date: Fri, 26 May 2023 12:02:57 +0000 Subject: [PATCH] `effect` docs --- src/func/instances.rs | 4 +++- src/func/instances/effect.rs | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/func/instances.rs b/src/func/instances.rs index 02ae552..3eb2c52 100644 --- a/src/func/instances.rs +++ b/src/func/instances.rs @@ -4,13 +4,15 @@ //! //! For [`MonadFail`] examples, see [`result`][^research]. //! -//! For the simplest form (even ChatGPT can understand it! lol) of [`Monad`], see [`solo`][^production]. +//! For the simplest form of [`Monad`], see [`solo`][^production]. //! //! For async support, see [`future`][^production][^research] and [`tryfuture`][^production][^research]. //! //! For "creative" execution models, see [`lazy`][^research] and [`stackless`][^research]. //! //! For combining monads, see [`composition`][^research]. +//! +//! For adding extra metadata to values, see [`effect`][^research]. //! //! [^production]: instances expected to be used in production. //! diff --git a/src/func/instances/effect.rs b/src/func/instances/effect.rs index 38dc146..d4ef2db 100644 --- a/src/func/instances/effect.rs +++ b/src/func/instances/effect.rs @@ -1,13 +1,20 @@ +//! [Monad] for passing and combining metadata related to the evaluation of values. + use crate::func::*; +/// Metadata type. pub trait Effect { + /// Used in [`Pure::pure`]. fn e_pure() -> Self; + /// Used in [`ApplicativeLA2::la2`] and other [`Applicative`] methods. fn e_seq(lhs: Self, rhs: Self) -> Self; + /// Used in [`Monad::bind`] and other [`Monad`] methods. fn e_after(self, effect: Self) -> Self; } +/// Value and related metadata. #[derive(Clone)] pub struct WithEffect { pub value: A,