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

does it makes sense to have a translateKleisli #98

Closed
dvic opened this issue May 15, 2017 · 4 comments
Closed

does it makes sense to have a translateKleisli #98

dvic opened this issue May 15, 2017 · 4 comments

Comments

@dvic
Copy link
Contributor

dvic commented May 15, 2017

Hi!

Does it makes sense to have something like this in the library (transforming a Kleisli into the target effect if it's part of the stack):

  def translateKleisli[T[_], R, U, S, A](e: Eff[R, A], s: S)(
      implicit mx: Member.Aux[Kleisli[T, S, ?], R, U],
      m: T |= U): Eff[U, A] =
    interpret.translate(e) {
      new Translate[Kleisli[T, S, ?], U] {
        override def apply[X](kv: Kleisli[T, S, X]): Eff[U, X] = {
          send[T, U, X](kv.run(s))
        }
      }
    }

I only saw support for Reader (which is Kleisli with Id as an effect) in the library and I wondered if there was a particular reason for this (I thought I'd ask before preparing a PR).

Thanks for the effort by the way, really like this library!

@edmundnoble
Copy link
Contributor

This is interesting. It's like a combination of runReader and ReaderT. I can see this being useful.

@etorreborre
Copy link
Member

I haven't had a use-case for Kleisli as an effect but I can see where that would be useful. Yes please go ahead with a PR.

@dvic
Copy link
Contributor Author

dvic commented May 16, 2017

Cool! I'm going to make a PR for this. Shall I place it in ReaderInterpretation along with the Reader interpretors?

@edmundnoble
Copy link
Contributor

That sounds apt to me.

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

3 participants