1
\$\begingroup\$

I'm working on arrow library for scala

I've come with some new typeclass, which looks like generalized Functor

trait Project[F[_]] extends Functor[F]{
  def project[=>:[_,_], A, B](f: A =>: B)(implicit ar: ArrowChoice[=>:]): F[A] =>: F[B]

  def map[A, B](fa: F[A])(f: A => B): F[B] = project[Function1, A, B](f).apply(fa)
}

where ArrowChoice is subtype of Arrow

example of such typeclass instance could be

implicit def validationProject[E] = new Project[Validation[E, ?]] {
  def project[=>:[_, _], A, B](f: A =>: B)(implicit ar: ArrowChoice[=>:]): Validation[E, A] =>: Validation[E, B] =
    (ar.id[E] +++ f).dimap(_.disjunction, _.validation)
}

However I have some doubt about such definition:

  1. Is name Project is clear enough? Isn't it confusing or dissonating for potential user? Could it be that similar things were already discussed in some blogs or category theory and have some known label?

  2. Is extending Functor a good idea? In following example we have already Functor for Validation[E, ?] defined here. Should I bother they could conflict if user will import too much?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.