pub struct Lan<G, H, A, B>{ /* private fields */ }Expand description
Left Kan Extension — Lan G H A ≅ ∃B. (G B → A, H B).
Encodes a value H B together with a way to extract A from G B.
The intermediate type B is visible in Rust (unlike Haskell’s existential)
because Rust lacks first-class existential types.
§Key properties
- Functor in A:
fmapcomposes onto the extract function, no bounds needed. - Specialisation:
Lan<IdentityF, F, A, B>is isomorphic toCoyoneda<F, A>. - Lower: Given a natural transformation
H ~> G, collapse toA.
Implementations§
Source§impl<G, H, A, B> Lan<G, H, A, B>
impl<G, H, A, B> Lan<G, H, A, B>
Sourcepub fn new(
source: <H as HKT>::Of<B>,
f: impl Fn(<G as HKT>::Of<B>) -> A + 'static,
) -> Lan<G, H, A, B>
pub fn new( source: <H as HKT>::Of<B>, f: impl Fn(<G as HKT>::Of<B>) -> A + 'static, ) -> Lan<G, H, A, B>
Construct a Lan from a source value and an extract function.
Sourcepub fn fmap<C>(self, f: impl Fn(A) -> C + 'static) -> Lan<G, H, C, B>where
C: 'static,
pub fn fmap<C>(self, f: impl Fn(A) -> C + 'static) -> Lan<G, H, C, B>where
C: 'static,
Map a function over the result type. No bounds on G or H required.
Sourcepub fn lower<NT>(self) -> Awhere
NT: NaturalTransformation<H, G>,
pub fn lower<NT>(self) -> Awhere
NT: NaturalTransformation<H, G>,
Collapse the Lan using a natural transformation NT: H ~> G.
Applies the nat-trans to the source, then extracts the result.
Auto Trait Implementations§
impl<G, H, A, B> !RefUnwindSafe for Lan<G, H, A, B>
impl<G, H, A, B> !Send for Lan<G, H, A, B>
impl<G, H, A, B> !Sync for Lan<G, H, A, B>
impl<G, H, A, B> !UnwindSafe for Lan<G, H, A, B>
impl<G, H, A, B> Freeze for Lan<G, H, A, B>
impl<G, H, A, B> Unpin for Lan<G, H, A, B>
impl<G, H, A, B> UnsafeUnpin for Lan<G, H, A, B>
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