Skip to content

Instantly share code, notes, and snippets.

@clementi
Last active April 18, 2025 15:56
Show Gist options
  • Select an option

  • Save clementi/5505d24d412c6a04af63fb73bd051262 to your computer and use it in GitHub Desktop.

Select an option

Save clementi/5505d24d412c6a04af63fb73bd051262 to your computer and use it in GitHub Desktop.
lspath in Scala 3 with Cats and Cats Effect
//> using scala "3.6.3"
//> using dep org.typelevel::cats-effect:3.5.7
import cats.effect.ExitCode
import cats.effect.IO
import cats.effect.IOApp
import cats.implicits.*
import java.io.File
object Main extends IOApp:
override def run(args: List[String]): IO[ExitCode] =
for
path <- getPath
_ <- path.traverse(IO.println)
yield ExitCode.Success
private def getPath: IO[List[String]] =
sys.env.get("PATH")
.getOrElse("")
.pure[IO]
.map(_.split(File.pathSeparator))
.map(_.toList)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment