Skip to content

Instantly share code, notes, and snippets.

@gvolpe
Created January 31, 2023 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gvolpe/088f6d1a1a8071304b6ae2db444d687c to your computer and use it in GitHub Desktop.
Save gvolpe/088f6d1a1a8071304b6ae2db444d687c to your computer and use it in GitHub Desktop.
The "-Wvalue-discard" flag doesn't seem to work with the `IO` monad
//> using scala "3.3.0-RC1"
//> using lib "org.typelevel::cats-effect:3.4.5"
//> using plugin "com.github.ghik:::zerowaste:0.2.3"
//> using options "-Wunused:imports"
//> using options "-Werror"
//> using options "-Wvalue-discard"
import cats.effect.*
object Main extends IOApp.Simple:
def run: IO[Unit] =
IO.pure("discarded")
IO.println("foo") *> IO.println("bar")
@mpilquist
Copy link

Still an issue with 3.4.0.

//> using scala "3.4.0"
//> using dep "org.typelevel::cats-effect:3.5.4"
//> using options "-Wunused:imports"
//> using options "-Werror"
//> using options "-Wvalue-discard"

import cats.effect.*

object Main extends IOApp.Simple:
  def run: IO[Unit] =
    IO.pure("discarded")
    IO.println("foo") *> IO.println("bar")

@TonioGela
Copy link

TonioGela commented Apr 12, 2024

As @BalmungSan pointed out here, you're searching for nonunit-statements

//> using scala 3.4.1
//> using toolkit typelevel::latest
//> using options -Wunused:imports, -Werror, -Wnonunit-statement

import cats.effect.*

object Main extends IOApp.Simple:
  def run: IO[Unit] =
    IO.pure("discarded")
    IO.println("foo") *> IO.println("bar")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment