Created
May 21, 2021 21:28
-
-
Save clementi/5505d24d412c6a04af63fb73bd051262 to your computer and use it in GitHub Desktop.
lspath in Scala 3 with Cats and Cats Effect
This file contains 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
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