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

Override MonadCancel#bracketFull in monad transformers instances #2013

Closed
Baccata opened this issue May 28, 2021 · 0 comments
Closed

Override MonadCancel#bracketFull in monad transformers instances #2013

Baccata opened this issue May 28, 2021 · 0 comments

Comments

@Baccata
Copy link
Contributor

Baccata commented May 28, 2021

Context

In the following example, only "goodbye" gets printed :

import cats.effect.IOApp
import cats.effect.IO
import cats.effect.std._
import cats.effect.kernel.syntax.all._
import cats.data.OptionT

object Main extends IOApp.Simple {

  type Foo[A] = OptionT[IO, A]

  val prog: Foo[Int] = OptionT[IO, Int](IO.pure(None))

  def run: IO[Unit] = {
    prog
      .guarantee(Console[Foo].println("hit guarantee"))
      .value
      .productR(IO.println("goodbye"))
  }
}

This is caused by the generic implementation of bracketFull which doesn't take into consideration the algebraic "unhappy" cases of monad transformers.

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

Successfully merging a pull request may close this issue.

2 participants