pub struct Cofree<F, A>where
F: HKT,{
pub head: A,
pub tail: Box<<F as HKT>::Of<Cofree<F, A>>>,
}Expand description
Cofree Comonad — the dual of the Free Monad.
Cofree<F, A> pairs a value A at each node with a branching structure
determined by F. The choice of F determines the shape:
OptionF→ a non-empty list (finite stream)VecF→ a rose treeIdentityF→ an infinite stream
Each node carries a value (head) and subtrees (tail).
Fields§
§head: AThe value at this node.
tail: Box<<F as HKT>::Of<Cofree<F, A>>>The subtrees, with branching structure determined by F.
Implementations§
Source§impl<F, A> Cofree<F, A>
impl<F, A> Cofree<F, A>
Sourcepub fn fmap<B>(self, f: impl Fn(A) -> B) -> Cofree<F, B>
pub fn fmap<B>(self, f: impl Fn(A) -> B) -> Cofree<F, B>
Map a function over all head values in the tree.
Auto Trait Implementations§
impl<F, A> Freeze for Cofree<F, A>where
A: Freeze,
impl<F, A> RefUnwindSafe for Cofree<F, A>
impl<F, A> Send for Cofree<F, A>
impl<F, A> Sync for Cofree<F, A>
impl<F, A> Unpin for Cofree<F, A>where
A: Unpin,
impl<F, A> UnsafeUnpin for Cofree<F, A>where
A: UnsafeUnpin,
impl<F, A> UnwindSafe for Cofree<F, A>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more