Last active
April 18, 2025 15:56
-
-
Save clementi/5505d24d412c6a04af63fb73bd051262 to your computer and use it in GitHub Desktop.
lspath in Scala 3 with Cats and Cats Effect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> 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