Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distributive members are swapped compared to Haskell/Purescript #2034

Open
lemastero opened this issue Jan 10, 2019 · 1 comment
Open

Distributive members are swapped compared to Haskell/Purescript #2034

lemastero opened this issue Jan 10, 2019 · 1 comment

Comments

@lemastero
Copy link
Contributor

lemastero commented Jan 10, 2019

Implementation of Distributive looks like this:

trait Distributive[F[_]] extends Functor[F] { self =>
  def distribute[G[_]:Functor,A,B](fa: G[A])(f: A => F[B]): F[G[B]]
  def cosequence[G[_]:Functor,A](fa: G[F[A]]): F[G[A]]
}

But in Haskell and Purescript this looks differently:

collect :: Functor f => (a -> g b) -> f a -> g (f b)
distribute :: Functor f => f (g a) -> g (f a)

So probably in Scala implementation should be more like this:

trait Distributive[F[_]] extends Functor[F] {
  def collect[G[_]:Functor,A,B](fa: G[A])(f: A => F[B]): F[G[B]]
  def distribute[G[_]:Functor,A](fa: G[F[A]]): F[G[A]]
}

well, if we want to have co-name then maybe:

trait Distributive[F[_]] extends Functor[F] {
  def cotraverse[G[_]:Functor,A,B](fa: G[A])(f: A => F[B]): F[G[B]]
  def distribute[G[_]:Functor,A](fa: G[F[A]]): F[G[A]]
}

Maybe I am missing something :)

@lemastero
Copy link
Contributor Author

Cats Distributive also has this feature/bug. Relevant PR: typelevel/cats#2046

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant