Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kitlangton/parallel-for
Automatically parallelize your for-comprehensions at compile time.
https://github.com/kitlangton/parallel-for
Last synced: 5 days ago
JSON representation
Automatically parallelize your for-comprehensions at compile time.
- Host: GitHub
- URL: https://github.com/kitlangton/parallel-for
- Owner: kitlangton
- License: apache-2.0
- Created: 2022-02-05T04:39:01.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-30T14:10:08.000Z (about 1 month ago)
- Last Synced: 2024-10-11T08:44:38.282Z (26 days ago)
- Language: Scala
- Size: 113 KB
- Stars: 131
- Watchers: 6
- Forks: 10
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Parallel For
[![Release Artifacts][Badge-SonatypeReleases]][Link-SonatypeReleases]
[![Snapshot Artifacts][Badge-SonatypeSnapshots]][Link-SonatypeSnapshots]> **Automatically parallelize your for comprehensions at compile time.**
```sbt
// build.sbt
libraryDependencies ++= Seq(
"io.github.kitlangton" %% "parallel-for" % "0.0.6",
"io.github.kitlangton" %% "parallel-for-zio" % "0.0.6", // for ZIO 2
"io.github.kitlangton" %% "parallel-for-zio1" % "0.0.6", // for ZIO 1
"io.github.kitlangton" %% "parallel-for-zio-query" % "0.0.6", // for ZIO QUERY (for ZIO 2)
"io.github.kitlangton" %% "parallel-for-cats-effect-3" % "0.0.6", // for Cats Effect 3
)
```## Example
Wrapping a for-comprehension in `par` will automatically parallelize it at compile time.
```scala
import parallelfor._
import parallelfor.interop.zio._ // Change this line depending on your effect system
import zio._val program =
par {
for {
users <- loadUsers
files <- loadFiles
config <- loadConfig
result <- process(users, files, config)
_ <- fireTheMissiles
} yield result
}
```The `par` macro will rewrite the above program to—*essentially*—the following:
```scala
val program =
for {
(users, files, config, _) <- loadUsers zipPar loadFiles zipPar loadConfig zipPar fireTheMissiles
result <- process(users, files, config)
} yield result
```***Neato!***
Similar project: [VirtusLab/avocADO] (only for Scala 3)
## TODO
- [x] Work with ZIO and ZManaged
- [x] Maximize parallelization with topological sorting
- [x] Get it to work with val assignments inside of for-comprehensions
- [x] Set up publishing
- [x] Generalize to work with any zippable structure (implement against `Parallelizable` type-class)
- [ ] Fix withFilter interaction
- [ ] Cross-build for JS and Native
- [ ] Cross-build against 2.11/2.12
- [ ] Get it to work with Scala 3[Badge-SonatypeReleases]: https://img.shields.io/nexus/r/https/oss.sonatype.org/io.github.kitlangton/parallel-for_2.13.svg "Sonatype Releases"
[Badge-SonatypeSnapshots]: https://img.shields.io/nexus/s/https/oss.sonatype.org/io.github.kitlangton/parallel-for_2.13.svg "Sonatype Snapshots"
[Link-SonatypeSnapshots]: https://oss.sonatype.org/content/repositories/snapshots/io/github/kitlangton/parallel-for_2.13/ "Sonatype Snapshots"
[Link-SonatypeReleases]: https://oss.sonatype.org/content/repositories/releases/io/github/kitlangton/parallel-for_2.13/ "Sonatype Releases"
[VirtusLab/avocADO]: https://github.com/VirtusLab/avocADO