Trait Pure

Source
pub trait Pure: Higher {
    // Required method
    fn pure(x: Self::Param) -> Self;

    // Provided method
    fn unit() -> Self
       where Self: Higher<Param = ()> + Sized { ... }
}
Expand description

Typeclass for lifting values into a context.

Required Methods§

Source

fn pure(x: Self::Param) -> Self

Lift a value into a context.

§Examples
use rust2fun::prelude::*;

let actual = Option::pure(1);
assert_eq!(Some(1), actual);

Provided Methods§

Source

fn unit() -> Self
where Self: Higher<Param = ()> + Sized,

Lift Unit into a context. This is a convenience method for pure(()).

§Examples
use rust2fun::prelude::*;

let actual = Option::unit();
assert_eq!(Some(()), actual);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<A> Pure for Option<A>

Source§

fn pure(x: A) -> Option<A>

Source§

impl<A> Pure for Box<A>

Source§

fn pure(x: A) -> Self

Source§

impl<A> Pure for LinkedList<A>

Source§

fn pure(x: A) -> Self

Source§

impl<A> Pure for VecDeque<A>

Source§

fn pure(x: A) -> Self

Source§

impl<A> Pure for Vec<A>

Source§

fn pure(x: A) -> Self

Source§

impl<A, E> Pure for Result<A, E>

Source§

fn pure(x: A) -> Self

Source§

impl<A: Eq + Hash> Pure for HashSet<A>

Source§

fn pure(x: A) -> Self

Source§

impl<A: Ord> Pure for BinaryHeap<A>

Source§

fn pure(x: A) -> Self

Source§

impl<A: Ord> Pure for BTreeSet<A>

Source§

fn pure(x: A) -> Self

Implementors§

Source§

impl<A, E: Semigroup> Pure for Validated<A, E>

Source§

impl<T> Pure for NEVec<T>