JasonShin / fp-core.rs

A library for functional programming in Rust
MIT License
1.34k stars 66 forks source link

Massive issues with naming convention for generics throughout fp-core #38

Closed JasonShin closed 5 years ago

JasonShin commented 5 years ago

The aim of this ticket is to come up with a standard for naming convention used for generics throughout fp-core.

Right now we are facing major issues with this and it eventually leads to incorrect type class signatures.

For example, I came up with below signature for traverse

trait Traverse<A, B, F, G>: HKT<G, B> + HKT3<G, F, B> + Applicative<A, F, B> {
    fn traverse<FB>(&self, f: FB) -> <Self as HKT3<G, F, B>>::Target2
    where
        FB: FnOnce(A) -> <Self as HKT<G, B>>::Target;
}

G here is used for Applicative and F is for Functor. However, due to the nature of Rust, which requires you to pass-through generics to its children, F in Apply is currently used for f (mappable) and it is already incorrect.

The ticket aims to standardise this process and come up with rules around generic name usage.

JasonShin commented 5 years ago

This isn't causing any issues to the existing typeclasses but it will restrict us from scaling out (adding more typeclasses)

JasonShin commented 5 years ago

We can close this as the PR by @hemangandhi has solved this issue initially. This issue is an ongoing one and has to be part of the coding standard.