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

FreeT.inject helper function #1534

Closed
VledicFranco opened this issue Feb 10, 2017 · 2 comments
Closed

FreeT.inject helper function #1534

VledicFranco opened this issue Feb 10, 2017 · 2 comments

Comments

@VledicFranco
Copy link

VledicFranco commented Feb 10, 2017

For a project I am using FreeT with multiple algebras, I noticed that there is no helper functions to inject an algebra into a coproduct of algebras for free transformers, so I wrote one similar to the Free.inject like this:

  /**
    * This method is used to defer the application of an Inject[F, G]
    * instance. The actual work happens in
    * `FreeTInjectPartiallyApplied#apply`.
    *
    * This method exists to allow the `F`, `M` and `G` parameters to be
    * bound independently of the `A` parameter below.
    */
  def inject[F[_], M[_], G[_]]: FreeTInjectPartiallyApplied[F, M, G] =
    new FreeTInjectPartiallyApplied

  /**
    * Pre-application of an injection to a `F[A]` value for a FreeT
    * with applicative `M[_]`.
    */
  final class FreeTInjectPartiallyApplied[F[_], M[_], G[_]] {
    def apply[A](fa: F[A])(implicit I: Inject[F, G], m: Applicative[M]): FreeT[G, M, A] =
      FreeT.liftF[G, M, A](I.inj(fa))
  }

It is working and I was wondering if this is a good contribution to the library.

Cheers! :)

@njayinthehouse
Copy link

Is this issue still open? If so, what exactly is required? I'd like to contribute. :)

valydia added a commit to valydia/cats that referenced this issue Feb 11, 2018
valydia pushed a commit to valydia/cats that referenced this issue Mar 7, 2018
valydia pushed a commit to valydia/cats that referenced this issue Mar 7, 2018
kailuowang pushed a commit that referenced this issue Mar 16, 2018
* Add FreeT.inject helper function (#1534)

* Rename FreeT.inject to FreeT.liftInject (#1534)

* Add Free.liftInject helper function (#1534)
@kubukoz
Copy link
Member

kubukoz commented Apr 15, 2018

Seems to have been fixed by #2169

@LukaJCB LukaJCB closed this as completed Apr 15, 2018
kailuowang pushed a commit that referenced this issue Nov 6, 2019
* Add FreeT.inject helper function (#1534)

* Rename FreeT.inject to FreeT.liftInject (#1534)

* Add Free.liftInject helper function (#1534)

* Add CommutativeMonoid[Option[A]] instance (#2725)

* Update laws

* Format the codebase

* Remove unnecessary change

* Make instance helper class private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants