deep_causality_haft/alias/alias_functor.rs
1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5
6use crate::{Functor, HKT, Satisfies};
7
8/// Alias trait for `Functor` providing more intuitive method names.
9///
10/// - `transform` → `fmap`: Applies a function to the value inside a container.
11pub trait AliasFunctor<F: HKT>: Functor<F> {
12 /// Alias for `fmap`. Transforms the value inside a container.
13 #[inline]
14 fn transform<A, B, Func>(m_a: F::Type<A>, f: Func) -> F::Type<B>
15 where
16 A: Satisfies<F::Constraint>,
17 B: Satisfies<F::Constraint>,
18 Func: FnMut(A) -> B,
19 {
20 Self::fmap(m_a, f)
21 }
22}
23
24// Blanket implementation
25impl<T, F> AliasFunctor<F> for T
26where
27 T: Functor<F>,
28 F: HKT,
29{
30}