Struct naan::bifunctor::Join

source ·
pub struct Join<M, T, A>(_, _);
Expand description

Join is a newtype that provides a single fmap implementation for Bifunctors that have the same type for both parameters, e.g. Result<A, A> or (A, A).

use naan::prelude::*;

let r = Result::<(), ()>::Ok(()) // Result<(), ()>
                                .join()
                                .fmap(|_| format!("hello!")) // Result<String, String>
                                .unjoin();

assert_eq!(r, Ok(format!("hello!")));

Implementations§

source§

impl<M, T, A> Join<M, T, A>

source

pub fn join(t: T) -> Join<M, T, A>where M: HKT2<T<A, A> = T>,

Wrap a bifunctor in Join

source

pub fn unjoin(self) -> T

Destroy this Join, yielding the inner type

Trait Implementations§

source§

impl<M, T, A> Functor<JoinHKT<M>, A> for Join<M, T, A>where JoinHKT<M>: HKT1<T<A> = Self>, M: HKT2 + HKT2<T<A, A> = T>, T: Bifunctor<M, A, A>,

source§

fn fmap<AB, B>(self, f: AB) -> <JoinHKT<M> as HKT1>::T<B>where AB: F1<A, Ret = B>,

Use a function from A -> B to transform an F<A> to an F<B>.

Auto Trait Implementations§

§

impl<M, T, A> RefUnwindSafe for Join<M, T, A>where A: RefUnwindSafe, M: RefUnwindSafe, T: RefUnwindSafe,

§

impl<M, T, A> Send for Join<M, T, A>where A: Send, M: Send, T: Send,

§

impl<M, T, A> Sync for Join<M, T, A>where A: Sync, M: Sync, T: Sync,

§

impl<M, T, A> Unpin for Join<M, T, A>where A: Unpin, M: Unpin, T: Unpin,

§

impl<M, T, A> UnwindSafe for Join<M, T, A>where A: UnwindSafe, M: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<F, A, TF, T> Sequence<F, A, TF> for T

source§

fn sequence<Ap>(self) -> Ap::T<F::T<A>>where Self: Sized + Traversable<F, Ap::T<A>, A, TF> + Foldable<F, Ap::T<A>>, Ap: HKT1, Ap::T<A>: Applicative<Ap, A> + ApplyOnce<Ap, A>, Ap::T<TF>: Applicative<Ap, TF> + ApplyOnce<Ap, TF>, Ap::T<F::T<A>>: Applicative<Ap, F::T<A>> + ApplyOnce<Ap, F::T<A>>, F: HKT1<T<Ap::T<A>> = Self>,

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.