Trait comonoid::Comonoid [] [src]

pub trait Comonoid: Sized {
    fn counit(self);
    fn comult(self) -> (Self, Self);
}

A comonoid in a monoidal category is a monoid in the dual category, what is the problem?

Being the dual to a monoid, it consists of:

  • The dual to unit, a function from T to () called counit.
  • The dual to multiplication, a function from T to (T, T) called comult.

It is useful within Rust's ownership type system, to represent a type that can be both cloned and destroyed.

There is a trivial implementation of this trait for every type that implements Clone, as reflected by the Comonoidal newtype wrapper, with discard as counit, and duplicate as comult. The behaviour of counit and comult can be altered by the implementation of Drop and Clone, respectively.

Required Methods

The dual to the monoidal unit.

The dual to the monoidal multiplication.

Implementors