Skip to content

Instantly share code, notes, and snippets.

@clementi
Created May 21, 2021 21:28
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 clementi/5505d24d412c6a04af63fb73bd051262 to your computer and use it in GitHub Desktop.
Save clementi/5505d24d412c6a04af63fb73bd051262 to your computer and use it in GitHub Desktop.
lspath in Scala 3 with Cats and Cats Effect
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.map(IO.println).sequence
yield ExitCode.Success
private def getPath: IO[List[String]] =
sys.env.get("PATH")
.getOrElse("")
.split(File.pathSeparator)
.toList
.pure[IO]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment