feat: parTraverse -> fs2
This commit is contained in:
@@ -13,6 +13,8 @@
|
|||||||
//> using dep org.slf4j:slf4j-simple:2.0.17
|
//> using dep org.slf4j:slf4j-simple:2.0.17
|
||||||
//> using test.dep org.scalatest::scalatest::3.2.19
|
//> using test.dep org.scalatest::scalatest::3.2.19
|
||||||
//> using dep org.typelevel::cats-effect-testing-scalatest::1.6.0
|
//> using dep org.typelevel::cats-effect-testing-scalatest::1.6.0
|
||||||
|
//> using dep "co.fs2::fs2-core:3.11.0"
|
||||||
|
//> using dep co.fs2::fs2-io:3.11.0
|
||||||
|
|
||||||
// sensible defaults for warnings and compiler checks
|
// sensible defaults for warnings and compiler checks
|
||||||
//> using options -deprecation -unchecked -feature
|
//> using options -deprecation -unchecked -feature
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import com.monovore.decline.effect._
|
|||||||
import org.typelevel.log4cats.slf4j.Slf4jLogger
|
import org.typelevel.log4cats.slf4j.Slf4jLogger
|
||||||
import org.typelevel.log4cats.Logger
|
import org.typelevel.log4cats.Logger
|
||||||
|
|
||||||
|
import fs2.Stream
|
||||||
|
|
||||||
import assemblyIR as asm
|
import assemblyIR as asm
|
||||||
import cats.data.ValidatedNel
|
import cats.data.ValidatedNel
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -147,8 +149,13 @@ def compileCommandParallel(
|
|||||||
log: Boolean,
|
log: Boolean,
|
||||||
outDir: Option[Path]
|
outDir: Option[Path]
|
||||||
): IO[ExitCode] =
|
): IO[ExitCode] =
|
||||||
files
|
Stream
|
||||||
.parTraverse { file => compile(file.toAbsolutePath, outDir, log) }
|
.emits(files.toList)
|
||||||
|
.parEvalMapUnordered(Runtime.getRuntime.availableProcessors()) { file =>
|
||||||
|
compile(file.toAbsolutePath, outDir, log)
|
||||||
|
}
|
||||||
|
.compile
|
||||||
|
.toList
|
||||||
.map { exitCodes =>
|
.map { exitCodes =>
|
||||||
exitCodes.filter(_ != 0) match {
|
exitCodes.filter(_ != 0) match {
|
||||||
case Nil => ExitCode.Success
|
case Nil => ExitCode.Success
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ object semantics {
|
|||||||
toRename = (main +: chunks).toList
|
toRename = (main +: chunks).toList
|
||||||
res <- toRename
|
res <- toRename
|
||||||
.zip(scope.subscopes(toRename.size))
|
.zip(scope.subscopes(toRename.size))
|
||||||
.parTraverse(checkFunc)
|
.traverse(checkFunc)
|
||||||
(typedChunks, errors) = res.foldLeft((Chain.empty[microWacc.FuncDecl], Chain.empty[Error])) {
|
(typedChunks, errors) = res.foldLeft((Chain.empty[microWacc.FuncDecl], Chain.empty[Error])) {
|
||||||
case ((acc, err), (funcDecl, errors)) =>
|
case ((acc, err), (funcDecl, errors)) =>
|
||||||
(acc :+ funcDecl, err ++ errors)
|
(acc :+ funcDecl, err ++ errors)
|
||||||
|
|||||||
Reference in New Issue
Block a user