Awesome
Effect Zoo for Scala 3
Inspired by Effect Zoo for Haskell.
Effect Zoo provides:
-
Code gallery, where we can demonstrate and compare the syntax of different effect systems, when they are assigned the same task. The sources are located here.
-
Microbenchmark suite. See running instruction below.
Included scenarios (contests):
-
cdown
: The CountDown scenario from Haskell's Effect Zoo. Uses singleState
effect. -
sumh
: In the spirit of CountDown, but uses more effects:Reader
,Writer
,State
, etc. -
mulst
: Multiple instances ofState
effects used at the same time. Compares overhead of effect stack size, by running the same number ofState
operations, spread over a varying numberState
effects (1 to 5). -
reint
: The Reinterpretation scenario from Haskell's Effect Zoo. Demonstrates use of custom-defined effects as application modules, and effect reinterpretation as DI mechanism.
Included effect systems:
-
Cats Core. Plain monad transformers, used with manual lifting.
-
Cats IO. Typically, the same solution as Cats MTL, but with
IO
from Cats Effect as the base monad. -
Cats Eff. Don't confuse with Cats Effect.
-
ZIO. ZIO doesn't come with predefined standard effects such as
Reader
,Writer
andState
. In this project we explore several ways of implementing them. -
ZPure from ZIO Prelude.
-
Kyo.
There are many more effect systems for Scala (e.g. 3 more implementations of the Eff monad alone), but they are unmaintained and unavailable for Scala 2.13 or 3.x.
Running Microbenchmarks
-
Step 0: Ensure you have a modern terminal.
Without support for Unicode characters and True Color, charts won't be displayed properly. If you are on Windows, old
cmd.exe
or PowerShell will get you garbage on the screen. The New Terminal might work (unconfirmed). -
Step 1: Ensure you have Java 11 or newer.
-
Step 2: Have sbt installed.
-
Step 3: Get a local copy of this repo and launch sbt:
git clone https://github.com/marcinzh/effect-zoo.git cd effect-zoo sbt
-
Step 4: From sbt's command prompt, pick one method:
-
Run JMH by using predefined alias (takes ~20 minutes to complete):
runbench
-
Run JMH directly, with your own parameters, e.g:
bench/Jmh/run -i 3 -wi 3 -f1 -t1 -r 3 -w 3 .*Cdown
-
Run Effect-Zoo's own, simple microbenchmark tool. It's less accurate than JMH, but completes much sooner (under 3 minutes):
diy/run --all
-