From 583754353c88247db5c0452e1f42187da9fe30f3 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Fri, 2 Apr 2021 20:05:27 +0430 Subject: [PATCH 01/36] document supervisor data type. --- docs/datatypes/misc/index.md | 1 + docs/datatypes/misc/supervisor.md | 100 ++++++++++++++++++++++++++++++ website/sidebars.json | 3 +- 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 docs/datatypes/misc/supervisor.md diff --git a/docs/datatypes/misc/index.md b/docs/datatypes/misc/index.md index 5c544b7e7dd4..eef7eb12749d 100644 --- a/docs/datatypes/misc/index.md +++ b/docs/datatypes/misc/index.md @@ -6,3 +6,4 @@ title: "Summary" - **[Chunk](chunk.md)** — ZIO `Chunk`: Fast, Pure Alternative to Arrays - **[Schedule](schedule.md)** — A `Schedule` is a model of a recurring schedule, which can be used for repeating successful `IO` values, or retrying failed `IO` values. - **[Has](has.md)** - A `Has` is used to express an effect's dependency on a service of type `A`. +- **[Supervisor](supervisor.md)** — Supervising the launching and termination of fibers. diff --git a/docs/datatypes/misc/supervisor.md b/docs/datatypes/misc/supervisor.md new file mode 100644 index 000000000000..6db3ee4cb0c2 --- /dev/null +++ b/docs/datatypes/misc/supervisor.md @@ -0,0 +1,100 @@ +--- +id: supervisor +title: "Supervisor" +--- + +A `Supervisor[A]` is allowed to supervise the launching and termination of fibers, producing some visible value of type `A` from the supervision. + +## Creation + +### track +The `track` creates a new supervisor that tracks children in a set. It takes a boolean `weak` parameter as input, which indicates whether track children in a `Weakset` or not. + + +```scala mdoc:invisible +import zio.Supervisor +``` + +```scala mdoc +val supervisor = Supervisor.track(true) +``` + +We can periodically, report the status of the fibers of our program with the help of the Supervisor. + +### fibersIn +The `fibersIn` creates a new supervisor with an initial sorted set of fibers. + +In the following example we are creating a new supervisor from an initial set of fibers: + +```scala mdoc:invisible +import zio.{Ref, Fiber} +import scala.collection.immutable.SortedSet +def fibers: Seq[Fiber.Runtime[Any, Any]] = ??? +``` + +```scala mdoc +def fiberListSupervisor = for { + ref <- Ref.make(SortedSet.from(fibers)) + s <- Supervisor.fibersIn(ref) +} yield (s) +``` + +## Supervising + +Whenever we need to supervise a ZIO effect, we can call `ZIO#supervised` function, `supervised` takes a supervisor and return another effect. The behavior of children fibers is reported to the provided supervisor: + +```scala mdoc:invisible +import zio._ +import zio.console._ +import zio.clock._ +import zio.duration._ +def fib(n: Int): ZIO[Any, Nothing, Int] = ??? +``` + +```scala mdoc:silent +val supervised = supervisor.flatMap(s => fib(20).supervised(s)) +``` + +Now we can access all information of children fibers through the supervisor. + +## Example +In the following example we are going to periodically monitor the number of fibers throughout our application life cycle: + +```scala mdoc:silent +object SupervisorExample extends zio.App { + import zio.duration._ + + val program = for { + supervisor <- Supervisor.track(true) + fiber <- fib(20).supervised(supervisor).fork + policy = Schedule + .spaced(500.milliseconds) + .whileInputM[Any, Unit](_ => fiber.status.map(x => !x.isDone)) + logger <- monitorFibers(supervisor) + .repeat(policy).fork + _ <- logger.join + result <- fiber.join + _ <- putStrLn(s"fibonacci result: $result") + } yield () + + def monitorFibers(supervisor: Supervisor[Chunk[Fiber.Runtime[Any, Any]]]) = for { + length <- supervisor.value.map(_.length) + _ <- putStrLn(s"number of fibers: $length") + } yield () + + def fib(n: Int): ZIO[Clock, Nothing, Int] = + if (n <= 1) { + ZIO.succeed(1) + } else { + for { + _ <- sleep(500.milliseconds) + fiber1 <- fib(n - 2).fork + fiber2 <- fib(n - 1).fork + v2 <- fiber2.join + v1 <- fiber1.join + } yield v1 + v2 + } + + override def run(args: List[String]) = program.exitCode +} +``` diff --git a/website/sidebars.json b/website/sidebars.json index dcd04abdfe62..a6d1fe10b658 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -75,7 +75,8 @@ "datatypes/misc/index", "datatypes/misc/chunk", "datatypes/misc/schedule", - "datatypes/module/has" + "datatypes/module/has", + "datatypes/misc/supervisor" ] }, "services-sidebar": { From bc817fdc55952d5413cea5d7b66a2a29346d8d5f Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Fri, 2 Apr 2021 21:50:55 +0430 Subject: [PATCH 02/36] fix the "has" page url. --- website/sidebars.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/sidebars.json b/website/sidebars.json index a6d1fe10b658..08264d183fe5 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -75,7 +75,7 @@ "datatypes/misc/index", "datatypes/misc/chunk", "datatypes/misc/schedule", - "datatypes/module/has", + "datatypes/misc/has", "datatypes/misc/supervisor" ] }, From c918866c978200fac9193fc7be730833e33d37b4 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Fri, 2 Apr 2021 21:51:40 +0430 Subject: [PATCH 03/36] remove the runtime section. --- website/sidebars.json | 1 - 1 file changed, 1 deletion(-) diff --git a/website/sidebars.json b/website/sidebars.json index 08264d183fe5..2786ba7cefb8 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -65,7 +65,6 @@ "datatypes/resource/index", "datatypes/resource/managed" ], - "Runtime": [], "Streaming": [ "datatypes/stream/index", "datatypes/stream/stream", From 3ee148363ec475ab30cfdc69fcc2c2119d274068 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Sat, 3 Apr 2021 13:34:07 +0430 Subject: [PATCH 04/36] document clock service. --- docs/services/clock.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/services/clock.md b/docs/services/clock.md index 4f1e710dd398..abaae05d729e 100644 --- a/docs/services/clock.md +++ b/docs/services/clock.md @@ -3,5 +3,34 @@ id: clock title: "Clock" --- -Coming Soon +Clock service contains some functionality related to time and scheduling. +To get the current time in a specific time unit, the `currentTime` function takes a unit as `TimeUnit` and returns `UIO[Long]`: + +```scala mdoc:invisible +import zio.clock._ +import zio.console._ +import zio.duration._ +import zio.{URIO, ZIO} +import java.util.concurrent.TimeUnit +import java.time.DateTimeException +``` + +```scala mdoc:silent +val inMiliseconds: URIO[Clock, Long] = currentTime(TimeUnit.MILLISECONDS) +val inDays: URIO[Clock, Long] = currentTime(TimeUnit.DAYS) +``` + +To get current data time in the current timezone the `currentDateTime` function returns a ZIO effect containing `OffsetDateTime`. + +Also, the Clock service has a very useful functionality for sleeping and creating a delay between jobs. The `sleep` takes a `Duration` and sleep for the specified duration. It is analogous to `java.lang.Thread.sleep` function, but it doesn't block any underlying thread. It's completely non-blocking. + +In following example we are going to print the current time periodically by placing a one second`sleep` between each print call: + +```scala mdoc:silent +def printTimeForever: ZIO[Console with Clock, DateTimeException, Nothing] = + currentDateTime.flatMap(time => putStrLn(time.toString)) *> + sleep(1.seconds) *> printTimeForever +``` + +For scheduling purposes like retry and repeats, ZIO has a great data type called [Schedule](../datatypes/misc/schedule.md). From 1ad0ee048a820aa0a920ba68c0e7a2f2714fa6ec Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Sat, 3 Apr 2021 15:46:02 +0430 Subject: [PATCH 05/36] document clock service. --- docs/services/random.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/services/random.md b/docs/services/random.md index 17e826cb47c5..b341ab98ba32 100644 --- a/docs/services/random.md +++ b/docs/services/random.md @@ -3,4 +3,35 @@ id: clock title: "Clock" --- -Coming Soon \ No newline at end of file +Random service provides utilities to generate random numbers. It's a functional wrapper of `scala.util.Random`. This service contains various different pseudo-random generators like `nextInt`, `nextBolean` and `nextDouble`. Each random number generator functions return a `URIO[Random, T]` value. + +```scala mdoc:silent +import zio.random._ +import zio.console._ +for { + randomInt <- nextInt + _ <- putStrLn(s"A random Int: $randomInt") + randomChar <- nextPrintableChar + _ <- putStrLn(s"A random Char: $randomChar") + randomDouble <- nextDoubleBetween(1.0, 5.0) + _ <- putStrLn(s"A random double between 1.0 and 5.0: $randomDouble") +} yield () +``` + +Random service has a `setSeed` which helps us to alter the state of the random generator. It is useful when writing the test version of Random service when we need a generation of the same sequence of numbers. + +```scala mdoc:silent +for { + _ <- setSeed(0) + nextInts <- (nextInt zip nextInt) +} yield assert(nextInts == (-1155484576,-723955400)) +``` + +Also, it has a utility to shuffle a list or generating random samples from Gaussian distribution: + +* **shuffle** - Takes a list as an input and shuffles it. +* **nextGaussian** — Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0. + +> _**Note**:_ +> +> Random numbers that are generated via Random service are not cryptographically strong. Therefore it's not safe to use the ZIO Random service for security domains where a high level of security and randomness is required, such as password generation. From 7934b7f52510f5b25d9dd95f434999539a1d7c2f Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Sat, 3 Apr 2021 19:00:08 +0430 Subject: [PATCH 06/36] document system service. --- docs/services/system.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/services/system.md b/docs/services/system.md index f83d8d005f06..f970ad13853f 100644 --- a/docs/services/system.md +++ b/docs/services/system.md @@ -3,4 +3,34 @@ id: system title: "System" --- -Coming Soon \ No newline at end of file +System service contains several useful functions related to system environments and properties. Both of **system environments** and **system properties** are key/value pairs. They used to pass user-defined information to our application. + +Environment variables are global operating system level variables available to all applications running on the same machine while the properties are application-level variables provided to our application. + +## System Environment +The `env` function retrieve the value of an environment variable: + +```scala mdoc:silent +import zio.console._ +import zio.system._ +for { + user <- env("USER") + _ <- user match { + case Some(value) => putStr(s"The USER env is: $value") + case None => putStr("Oops! The USER env is not set") + } +} yield () +``` + +## System Property +Also, the System service has a `property function to retrieve the value of a system property: + +```scala mdoc:silent +for { + user <- property("LOG_LEVEL") + _ <- user match { + case Some(value) => putStr(s"The LOG_LEVEL property is: $value") + case None => putStr("Oops! The LOG_LEVEL property is not set") + } +} yield () +``` From 33479183ffd86a741781e964306b91e8e460c70d Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Sun, 4 Apr 2021 00:02:54 +0430 Subject: [PATCH 07/36] document blocking service. --- docs/services/blocking.md | 41 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/docs/services/blocking.md b/docs/services/blocking.md index 32d54aad3387..52b3ca62bc17 100644 --- a/docs/services/blocking.md +++ b/docs/services/blocking.md @@ -3,4 +3,43 @@ id: blocking title: "Blocking" --- -Coming Soon \ No newline at end of file +The **Blocking** service provides access to a thread pool that can be used for performing +blocking operations, such as thread sleeps, synchronous socket/file reads, and so forth. + +By default, ZIO is asynchronous and all effects will be executed on a default primary thread pool which is optimized for asynchronous operations. As ZIO uses a fiber-based concurrency model, if we run **Blocking I/O** or **CPU Work** workloads on a primary thread pool, they are going to monopolize all threads of **primary thread pool**. + +In the following example, we create 20 blocking tasks to run parallel on the primary async thread pool. Assume we have a machine with an 8 CPU core, so the ZIO creates a thread pool of size 16 (2 * 8). If we run this program, all of our threads got stuck, and the remaining 4 blocking tasks (20 - 16) haven't any chance to run on our thread pool: + +```scala mdoc:silent +import zio.{ZIO, URIO} +import zio.console._ +def blockingTask(n: Int): URIO[Console, Unit] = + putStrLn(s"running blocking task number $n") *> + ZIO.effectTotal(Thread.sleep(3000)) *> + blockingTask(n) + +val program = ZIO.foreachPar((1 to 100).toArray)(blockingTask) +``` + +ZIO has a separate **blocking thread pool** specially designed for **Blocking I/O** and, also **CPU Work** workloads. We should run blocking workloads on this thread pool to prevent interfering with the primary thread pool. + +The contract is that the thread pool will accept unlimited tasks (up to the available memory) +and continuously create new threads as necessary. + +The `blocking` operator takes a ZIO effect and return another effect that is going to run on a blocking thread pool: + +```scala mdoc:invisible:nest +import zio.blocking._ +val program = ZIO.foreachPar((1 to 100).toArray)(t => blocking(blockingTask(t))) +``` + +Also, we can directly imports a synchronous effect that does blocking IO into ZIO effect by using `effectBlocking`: + +```scala mdoc:silent:nest +def blockingTask(n: Int) = effectBlocking { + do { + println(s"running blocking task number $n") + Thread.sleep(3000) + } while (true) +} +``` From 163d28dc1174a2b974a74e506a1794c6387a61c1 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 08:09:48 +0430 Subject: [PATCH 08/36] document the introduction page of services. --- docs/services/index.md | 84 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 7 deletions(-) diff --git a/docs/services/index.md b/docs/services/index.md index 66a5f5a26976..566c8d83c877 100644 --- a/docs/services/index.md +++ b/docs/services/index.md @@ -1,12 +1,82 @@ --- id: index -title: "Summary" +title: "Introduction" --- -ZIO have some build-in services: +In the functional Scala as well as in object-oriented programming the best practice is to _Program to an interface, not an implementation_. This is the most important design principle in software development and helps us to write maintainable code by: -- **[Console](console.md)** — operations for reading/writing strings from/to the standard input, output, and error console. -- **[Clock](clock.md)** — -- **[Random](random.md)** — -- **[Blocking](blocking.md)** — -- **[System](system.md)** — \ No newline at end of file +* Allowing the client to hold an interface as a contract and don't worry about the implementation. The interface signature determines all operations that should be done. + +* Enabling a developer to write more testable programs. When we write a test for our business logic we don't have to run and interact with real services like databases which makes our test run very slow. If our code is correct our test code should always pass, there should be no hidden variables or depend on outside sources. We can't know that the database is always running correctly. We don't want to fail our tests because of the failure of external service. + +* Providing the ability to write more modular applications. So we can plug in different implementations for different purposes without a major modification. + +It is not mandatory but ZIO encourages us to follow this principle by bundling related functionality as an interface by using module pattern. + +Let's see how the `Console` service is defined and implemented in ZIO. To prevent naming collision with the original implementation we use the `Terminal` name to introduce the `Console` service. + +1. At the first step, we need to define our module `Terminal` as a type alias for `Has[Terminal.Service]`. + +2. Then inside the `Terminal` companion object, we should define the service definition in a trait named `Service`. Traits are how we define services. A service could be all the stuff that is related to one concept with singular responsibility. + +3. After that we need to implement our Service by creating a new Service and then lifting that entire implementation into the ZLayer data type by using the `succeed` operator. + +4. Finally, to create our API more ergonomic it's better to implement accessor methods for all of our service methods. + +```scala mdoc:invisible +import zio.{Has, UIO, Layer, ZLayer, ZIO, URIO} +``` + +```scala mdoc:silent +object terminal { + type Terminal = Has[Terminal.Service] + + object Terminal { + trait Service { + def putStr(line: String): UIO[Unit] + + def putStrLn(line: String): UIO[Unit] + } + + val live: Layer[Nothing, Terminal] = ZLayer.succeed { + new Service { + override def putStr(line: String): UIO[Unit] = + ZIO.effectTotal(print(line)) + + override def putStrLn(line: String): UIO[Unit] = + ZIO.effectTotal(println(line)) + } + } + } + + def putStr(line: => String): URIO[Terminal, Unit] = + ZIO.accessM(_.get.putStr(line)) + + def putStrLn(line: => String): URIO[Terminal, Unit] = + ZIO.accessM(_.get.putStrLn(line)) +} +``` + +This is how the ZIO services are created. Let's use the `Terminal` service in our application: + +```scala mdoc:silent +object TerminalExample extends zio.App { + import zio.RIO + import terminal._ + + private val application: RIO[Terminal, Unit] = putStrLn("Hello, World!") + + override def run(args: List[String]) = + application.provideLayer(Terminal.live).exitCode +} +``` + +When we write our entire `application` we don't care which implementation version of Terminal service will be injected into our `application`, later at the end of the day, it will be provided by methods like `provideLayer`. + +ZIO already provided 5 build-in services, when we use these services we don't need to provide their corresponding environment explicitly. The `ZEnv` environment is a type alias for all of these services and will be provided by ZIO to our effects: + +- **[Console](console.md)** — Operations for reading/writing strings from/to the standard input, output, and error console. +- **[Clock](clock.md)** — Contains some functionality related to time and scheduling. +- **[Random](random.md)** — Provides utilities to generate random numbers. +- **[Blocking](blocking.md)** — Provides access to a thread pool that can be used for performing blocking operations. +- **[System](system.md)** — Contains several useful functions related to system environments and properties. From 122d4cef3188dfca68f9cbe4ce16dc24b91a926f Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 08:29:23 +0430 Subject: [PATCH 09/36] fix the name and id of random page. --- docs/services/random.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/services/random.md b/docs/services/random.md index b341ab98ba32..d50505702578 100644 --- a/docs/services/random.md +++ b/docs/services/random.md @@ -1,6 +1,6 @@ --- -id: clock -title: "Clock" +id: random +title: "Random" --- Random service provides utilities to generate random numbers. It's a functional wrapper of `scala.util.Random`. This service contains various different pseudo-random generators like `nextInt`, `nextBolean` and `nextDouble`. Each random number generator functions return a `URIO[Random, T]` value. From 04ea09ee15400d1a1268c45449b5ea47a0c9104e Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 09:58:50 +0430 Subject: [PATCH 10/36] rename the talk page to videos. --- docs/resources/index.md | 2 +- docs/resources/learning/index.md | 2 +- docs/resources/learning/{talks.md => videos.md} | 4 ++-- website/sidebars.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename docs/resources/learning/{talks.md => videos.md} (99%) diff --git a/docs/resources/index.md b/docs/resources/index.md index 690fa3dad059..bc256d5dbd59 100644 --- a/docs/resources/index.md +++ b/docs/resources/index.md @@ -7,7 +7,7 @@ If you find a new great library, talk, resource, slides or project, related to Z ## Learning - [Articles](learning/articles.md) -- [Talks](learning/talks.md) +- [Videos](learning/videos.md) - [Cookbooks](learning/cookbooks.md) - [Cheat Sheets](learning/cheatsheets.md) - [Sample Projects](learning/sampleprojects.md) diff --git a/docs/resources/learning/index.md b/docs/resources/learning/index.md index 3e162e4f717b..496c9ac992f9 100644 --- a/docs/resources/learning/index.md +++ b/docs/resources/learning/index.md @@ -6,7 +6,7 @@ title: "Summary" If you find a new great talk, resource, slides or project, related to ZIO, consider adding to the list with your PR. - [Articles](articles.md) -- [Talks](talks.md) +- [Talks](videos.md) - [Cookbooks](cookbooks.md) - [Cheat Sheets](cheatsheets.md) - [Sample Projects](sampleprojects.md) diff --git a/docs/resources/learning/talks.md b/docs/resources/learning/videos.md similarity index 99% rename from docs/resources/learning/talks.md rename to docs/resources/learning/videos.md index ba97417ad0be..5d2422170f54 100644 --- a/docs/resources/learning/talks.md +++ b/docs/resources/learning/videos.md @@ -1,6 +1,6 @@ --- -id: talks -title: "Talks" +id: videos +title: "Videos" --- - [Acting Lessons for Scala Engineers with Akka and ZIO](https://www.youtube.com/watch?v=AQXBlbkf9wc) by [Salar Rahmanian](https://wwww.softinio.com) (November 2020) diff --git a/website/sidebars.json b/website/sidebars.json index 2786ba7cefb8..932e2bacc537 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -135,7 +135,7 @@ "Learning": [ "resources/learning/index", "resources/learning/articles", - "resources/learning/talks", + "resources/learning/videos", "resources/learning/cookbooks", "resources/learning/cheatsheets", "resources/learning/sampleprojects", From 5b6d41cf3144856db541146c3adc17728ab3ffca Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 10:02:37 +0430 Subject: [PATCH 11/36] remove duplicated links from resource index. --- docs/resources/index.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/docs/resources/index.md b/docs/resources/index.md index bc256d5dbd59..55ad9e139671 100644 --- a/docs/resources/index.md +++ b/docs/resources/index.md @@ -4,16 +4,3 @@ title: "Summary" --- If you find a new great library, talk, resource, slides or project, related to ZIO, consider adding to the list with your PR - -## Learning -- [Articles](learning/articles.md) -- [Videos](learning/videos.md) -- [Cookbooks](learning/cookbooks.md) -- [Cheat Sheets](learning/cheatsheets.md) -- [Sample Projects](learning/sampleprojects.md) -- [Project using ZIO](learning/projectsusingzio.md) - -## Ecosystem -- [Official ZIO Libraries](ecosystem/officials.md) -- [Libraries with Direct ZIO Support](ecosystem/directsupport.md) -- [Tools for ZIO](ecosystem/tools.md) From acf1814a9bb36748a94698e9792b54d4a0e45c9b Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 10:13:42 +0430 Subject: [PATCH 12/36] shorten the title. --- docs/resources/ecosystem/directsupport.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/ecosystem/directsupport.md b/docs/resources/ecosystem/directsupport.md index c9993bb25362..44ac435f53cb 100644 --- a/docs/resources/ecosystem/directsupport.md +++ b/docs/resources/ecosystem/directsupport.md @@ -1,6 +1,6 @@ --- id: directsupport -title: "Libraries with Direct ZIO Support" +title: "Libraries with ZIO Support" --- If you know a useful library that has direct support for ZIO, please consider [submitting a pull request](https://github.com/zio/zio/pulls) to add it to this list. From 5109a2bed9760de27826d77d8dbb3fb2a05db41e Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 10:20:37 +0430 Subject: [PATCH 13/36] create a separate page for project templates. --- docs/resources/ecosystem/templates.md | 9 +++++++++ docs/resources/ecosystem/tools.md | 2 -- website/sidebars.json | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 docs/resources/ecosystem/templates.md diff --git a/docs/resources/ecosystem/templates.md b/docs/resources/ecosystem/templates.md new file mode 100644 index 000000000000..46363a2e91a7 --- /dev/null +++ b/docs/resources/ecosystem/templates.md @@ -0,0 +1,9 @@ +--- +id: templates +title: "Project Templates" +--- + +List of project starters, bootstrap tools or, templates. + +- [zio-akka-quickstart.g8](https://github.com/ScalaConsultants/zio-akka-quickstart.g8): A Giter8 template for a basic Scala application build using ZIO, Akka HTTP and Slick +- [zio-dotty-quickstart.g8](https://github.com/ScalaConsultants/zio-dotty-quickstart.g8): A Giter8 template for a basic Dotty application build using ZIO diff --git a/docs/resources/ecosystem/tools.md b/docs/resources/ecosystem/tools.md index 0336fcf67fa9..3bb36b058e32 100644 --- a/docs/resources/ecosystem/tools.md +++ b/docs/resources/ecosystem/tools.md @@ -5,5 +5,3 @@ title: "Tools for ZIO" - [ZIO IntelliJ](https://github.com/zio/zio-intellij): A complimentary, community-developed plugin for IntelliJ IDEA, brings enhancements when using ZIO in your projects - [zio-shield](https://github.com/zio/zio-shield): Enforce best coding practices with ZIO -- [zio-akka-quickstart.g8](https://github.com/ScalaConsultants/zio-akka-quickstart.g8): A Giter8 template for a basic Scala application build using ZIO, Akka HTTP and Slick -- [zio-dotty-quickstart.g8](https://github.com/ScalaConsultants/zio-dotty-quickstart.g8): A Giter8 template for a basic Dotty application build using ZIO diff --git a/website/sidebars.json b/website/sidebars.json index 932e2bacc537..48e5fe3e3b0d 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -145,7 +145,8 @@ "resources/ecosystem/index", "resources/ecosystem/officials", "resources/ecosystem/directsupport", - "resources/ecosystem/tools" + "resources/ecosystem/tools", + "resources/ecosystem/templates" ] }, "about-sidebar": { From 54e9506bee58f54d8a2bc1b3fa6a23e4bd384d21 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 10:32:52 +0430 Subject: [PATCH 14/36] add zio-zmx into zio tools. --- docs/resources/ecosystem/tools.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/resources/ecosystem/tools.md b/docs/resources/ecosystem/tools.md index 3bb36b058e32..f49d164fb204 100644 --- a/docs/resources/ecosystem/tools.md +++ b/docs/resources/ecosystem/tools.md @@ -5,3 +5,4 @@ title: "Tools for ZIO" - [ZIO IntelliJ](https://github.com/zio/zio-intellij): A complimentary, community-developed plugin for IntelliJ IDEA, brings enhancements when using ZIO in your projects - [zio-shield](https://github.com/zio/zio-shield): Enforce best coding practices with ZIO +- [zio/zio-zmx](https://github.com/zio/zio-zmx) — Monitoring, Metrics and Diagnostics for ZIO \ No newline at end of file From f4d445c4e7c15072e1f826a9c5eef30611899429 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 10:37:28 +0430 Subject: [PATCH 15/36] use em-dash to separate titles from descriptions. --- docs/resources/ecosystem/tools.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/ecosystem/tools.md b/docs/resources/ecosystem/tools.md index f49d164fb204..6268b5cd9cbd 100644 --- a/docs/resources/ecosystem/tools.md +++ b/docs/resources/ecosystem/tools.md @@ -3,6 +3,6 @@ id: tools title: "Tools for ZIO" --- -- [ZIO IntelliJ](https://github.com/zio/zio-intellij): A complimentary, community-developed plugin for IntelliJ IDEA, brings enhancements when using ZIO in your projects -- [zio-shield](https://github.com/zio/zio-shield): Enforce best coding practices with ZIO +- [ZIO IntelliJ](https://github.com/zio/zio-intellij) — A complimentary, community-developed plugin for IntelliJ IDEA, brings enhancements when using ZIO in your projects +- [zio-shield](https://github.com/zio/zio-shield) — Enforce best coding practices with ZIO - [zio/zio-zmx](https://github.com/zio/zio-zmx) — Monitoring, Metrics and Diagnostics for ZIO \ No newline at end of file From 8184a377e106cd80ff3431f0135505cd4723f2d2 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 12:09:35 +0430 Subject: [PATCH 16/36] separate libraries into three section (official, community, zio compatible). --- .../{directsupport.md => community.md} | 19 ++++++++----------- docs/resources/ecosystem/compatible.md | 15 +++++++++++++++ docs/resources/ecosystem/index.md | 14 -------------- website/sidebars.json | 4 ++-- 4 files changed, 25 insertions(+), 27 deletions(-) rename docs/resources/ecosystem/{directsupport.md => community.md} (68%) create mode 100644 docs/resources/ecosystem/compatible.md delete mode 100644 docs/resources/ecosystem/index.md diff --git a/docs/resources/ecosystem/directsupport.md b/docs/resources/ecosystem/community.md similarity index 68% rename from docs/resources/ecosystem/directsupport.md rename to docs/resources/ecosystem/community.md index 44ac435f53cb..f890c24a46d8 100644 --- a/docs/resources/ecosystem/directsupport.md +++ b/docs/resources/ecosystem/community.md @@ -1,22 +1,17 @@ --- -id: directsupport -title: "Libraries with ZIO Support" +id: community +title: "Community ZIO Libraries" --- -If you know a useful library that has direct support for ZIO, please consider [submitting a pull request](https://github.com/zio/zio/pulls) to add it to this list. +List of first-class ZIO support libraries from the community: -- [cakeless](https://github.com/itkpi/cakeless): Wire your cakes automatically into zio environment - [caliban](https://github.com/ghostdogpr/caliban): Functional GraphQL backend in Scala -- [d4s](https://github.com/PlayQ/d4s): "Dynamo DB Database done Scala way". A library that allows accessing the DynamoDB in a purely functional way +- [cakeless](https://github.com/itkpi/cakeless): Wire your cakes automatically into zio environment - [distage](https://github.com/7mind/izumi): Staged, transparent and debuggable runtime & compile-time Dependency Injection Framework -- [elastic4s](https://github.com/sksamuel/elastic4s): Elasticsearch Scala Client - Reactive, Non Blocking, Type Safe, HTTP Client -- [idealingua](https://github.com/7mind/izumi): API Definition, Data Modeling and RPC Language, optimized for fast prototyping – like gRPC, but with a human face -- [logstage](https://github.com/7mind/izumi): Automatic structural logs from Scala string interpolations -- [neotypes](https://github.com/neotypes/neotypes): A Scala lightweight, type-safe & asynchronous driver for neo4j +- [idealingua](https://izumi.7mind.io/idealingua/): API Definition, Data Modeling and RPC Language, optimized for fast prototyping – like gRPC, but with a human face +- [logstage](https://izumi.7mind.io/logstage/): Automatic structural logs from Scala string interpolations - [rezilience](https://github.com/svroonland/rezilience): Utilities for resilience and handling of transient errors -- [scanamo](https://github.com/scanamo/scanamo): Simpler DynamoDB access for Scala - [slf4zio](https://github.com/mlangc/slf4zio): Simple convenience layer on top of SLF4J for ZIO -- [sttp](https://github.com/softwaremill/sttp): The Scala HTTP client you always wanted! - [tranzactio](https://github.com/gaelrenoux/tranzactio): ZIO wrapper for data access libraries like Doobie or Anorm - [ZIO Arrow](https://github.com/Neurodyne/zio-arrow) : Haskell Arrow meets ZIO. A deep composition and high performance applications - [zio-amqp](https://github.com/svroonland/zio-amqp): ZIO Streams based RabbitMQ client @@ -33,3 +28,5 @@ If you know a useful library that has direct support for ZIO, please consider [s - [zio-slf4j](https://github.com/NeQuissimus/zio-slf4j): Referentially transparent logging with slf4j - [zio-slick](https://github.com/rleibman/zio-slick): Bridge library between ZIO and Slick Functional Relational Mapping Library - [zio-test-akka-http](https://github.com/senia-psm/zio-test-akka-http): Akka-HTTP Route TestKit for zio-test + +If you know a useful library that has first-class ZIO support, please consider [submitting a pull request](https://github.com/zio/zio/pulls) to add it to this list. diff --git a/docs/resources/ecosystem/compatible.md b/docs/resources/ecosystem/compatible.md new file mode 100644 index 000000000000..2740af5d1d24 --- /dev/null +++ b/docs/resources/ecosystem/compatible.md @@ -0,0 +1,15 @@ +--- +id: compatible +title: "ZIO Compatible Libraries" +--- + +List of ZIO compatible libraries: + +- [d4s](https://github.com/PlayQ/d4s): "Dynamo DB Database done Scala way". A library that allows accessing the DynamoDB in a purely functional way +- [elastic4s](https://github.com/sksamuel/elastic4s): Elasticsearch Scala Client - Reactive, Non Blocking, Type Safe, HTTP Client +- [neotypes](https://github.com/neotypes/neotypes): A Scala lightweight, type-safe & asynchronous driver for neo4j +- [scanamo](https://github.com/scanamo/scanamo): Simpler DynamoDB access for Scala +- [sttp](https://github.com/softwaremill/sttp): The Scala HTTP client you always wanted! +- [doobie](https://github.com/tpolecat/doobie) — Functional JDBC layer for Scala. +- [fs2](https://github.com/typelevel/fs2) — Compositional, streaming I/O library for Scala +- [http4s](https://github.com/http4s/http4s) — A minimal, idiomatic Scala interface for HTTP diff --git a/docs/resources/ecosystem/index.md b/docs/resources/ecosystem/index.md deleted file mode 100644 index e17cd5b26975..000000000000 --- a/docs/resources/ecosystem/index.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -id: index -title: "Summary" ---- - -If you know a useful library that has direct support for ZIO, please consider [submitting a pull request](https://github.com/zio/zio/pulls) to add it to one of following categories. - -- [Official ZIO Libraries](officials.md) -- [Libraries with Direct ZIO Support](directsupport.md) -- [Tools for ZIO](tools.md) - -## ZIO Interoperability Libraries - -ZIO provides the ability to interoperate with other parts of the broader ecosystem, see [Interop](../../interop/index.md) for overview. diff --git a/website/sidebars.json b/website/sidebars.json index 48e5fe3e3b0d..718d03f0dba1 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -142,9 +142,9 @@ "resources/learning/poweredbyzio" ], "Ecosystem": [ - "resources/ecosystem/index", "resources/ecosystem/officials", - "resources/ecosystem/directsupport", + "resources/ecosystem/community", + "resources/ecosystem/compatible", "resources/ecosystem/tools", "resources/ecosystem/templates" ] From df2127964e9fabc5412e5b2e5f5ff96e2301d9b1 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 12:23:52 +0430 Subject: [PATCH 17/36] use em-dash to separate titles and descriptions. --- docs/resources/ecosystem/community.md | 46 ++++++++++----------- docs/resources/ecosystem/compatible.md | 10 ++--- docs/resources/ecosystem/officials.md | 20 ++++----- docs/resources/ecosystem/templates.md | 4 +- docs/resources/learning/projectsusingzio.md | 8 ++-- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/docs/resources/ecosystem/community.md b/docs/resources/ecosystem/community.md index f890c24a46d8..725a35266624 100644 --- a/docs/resources/ecosystem/community.md +++ b/docs/resources/ecosystem/community.md @@ -5,28 +5,28 @@ title: "Community ZIO Libraries" List of first-class ZIO support libraries from the community: -- [caliban](https://github.com/ghostdogpr/caliban): Functional GraphQL backend in Scala -- [cakeless](https://github.com/itkpi/cakeless): Wire your cakes automatically into zio environment -- [distage](https://github.com/7mind/izumi): Staged, transparent and debuggable runtime & compile-time Dependency Injection Framework -- [idealingua](https://izumi.7mind.io/idealingua/): API Definition, Data Modeling and RPC Language, optimized for fast prototyping – like gRPC, but with a human face -- [logstage](https://izumi.7mind.io/logstage/): Automatic structural logs from Scala string interpolations -- [rezilience](https://github.com/svroonland/rezilience): Utilities for resilience and handling of transient errors -- [slf4zio](https://github.com/mlangc/slf4zio): Simple convenience layer on top of SLF4J for ZIO -- [tranzactio](https://github.com/gaelrenoux/tranzactio): ZIO wrapper for data access libraries like Doobie or Anorm -- [ZIO Arrow](https://github.com/Neurodyne/zio-arrow) : Haskell Arrow meets ZIO. A deep composition and high performance applications -- [zio-amqp](https://github.com/svroonland/zio-amqp): ZIO Streams based RabbitMQ client -- [zio-aws](https://github.com/vigoo/zio-aws): Low-level AWS wrapper for ZIO for all AWS services using the AWS Java SDK v2 -- [zio-aws-s3](https://github.com/Neurodyne/zio-aws-s3): A lean, simple and efficient ZIO wrapper for AWS Java v2 S3 API by Boris V.Kuznetsov -- [zio-easymock](https://github.com/egast/zio-easymock): EasyMock mocking for zio-test -- [zio-email](https://github.com/funcit/zio-email): Purely functional email client -- [zio-event-sourcing](https://github.com/holinov/zio-event-sourcing): Purely functional concurrent and scalable persistance layer -- [zio-grpc](https://github.com/scalapb/zio-grpc): A native gRPC support for ZIO -- [zio-interop-log4j2](https://github.com/mlangc/zio-interop-log4j2): Fiber aware MDC logging for Log4j 2 -- [zio-kinesis](https://github.com/svroonland/zio-kinesis): ZIO Streams based AWS Kinesis client -- [zio-magic](https://github.com/kitlangton/zio-magic/): Construct ZLayers automagically (w/ helpful compile-time errors) -- [zio-saga](https://github.com/VladKopanev/zio-saga): Purely functional transaction management with Saga pattern -- [zio-slf4j](https://github.com/NeQuissimus/zio-slf4j): Referentially transparent logging with slf4j -- [zio-slick](https://github.com/rleibman/zio-slick): Bridge library between ZIO and Slick Functional Relational Mapping Library -- [zio-test-akka-http](https://github.com/senia-psm/zio-test-akka-http): Akka-HTTP Route TestKit for zio-test +- [caliban](https://github.com/ghostdogpr/caliban) — Functional GraphQL backend in Scala +- [cakeless](https://github.com/itkpi/cakeless) — Wire your cakes automatically into zio environment +- [distage](https://github.com/7mind/izumi) — Staged, transparent and debuggable runtime & compile-time Dependency Injection Framework +- [idealingua](https://izumi.7mind.io/idealingua/) — API Definition, Data Modeling and RPC Language, optimized for fast prototyping – like gRPC, but with a human face +- [logstage](https://izumi.7mind.io/logstage/) — Automatic structural logs from Scala string interpolations +- [rezilience](https://github.com/svroonland/rezilience) — Utilities for resilience and handling of transient errors +- [slf4zio](https://github.com/mlangc/slf4zio) — Simple convenience layer on top of SLF4J for ZIO +- [tranzactio](https://github.com/gaelrenoux/tranzactio) — ZIO wrapper for data access libraries like Doobie or Anorm +- [ZIO Arrow](https://github.com/Neurodyne/zio-arrow) — Haskell Arrow meets ZIO. A deep composition and high performance applications +- [zio-amqp](https://github.com/svroonland/zio-amqp) — ZIO Streams based RabbitMQ client +- [zio-aws](https://github.com/vigoo/zio-aws) — Low-level AWS wrapper for ZIO for all AWS services using the AWS Java SDK v2 +- [zio-aws-s3](https://github.com/Neurodyne/zio-aws-s3) — A lean, simple and efficient ZIO wrapper for AWS Java v2 S3 API by Boris V.Kuznetsov +- [zio-easymock](https://github.com/egast/zio-easymock) — EasyMock mocking for zio-test +- [zio-email](https://github.com/funcit/zio-email) — Purely functional email client +- [zio-event-sourcing](https://github.com/holinov/zio-event-sourcing) — Purely functional concurrent and scalable persistance layer +- [zio-grpc](https://github.com/scalapb/zio-grpc) — A native gRPC support for ZIO +- [zio-interop-log4j2](https://github.com/mlangc/zio-interop-log4j2) — Fiber aware MDC logging for Log4j 2 +- [zio-kinesis](https://github.com/svroonland/zio-kinesis) — ZIO Streams based AWS Kinesis client +- [zio-magic](https://github.com/kitlangton/zio-magic/) — Construct ZLayers automagically (w/ helpful compile-time errors) +- [zio-saga](https://github.com/VladKopanev/zio-saga) — Purely functional transaction management with Saga pattern +- [zio-slf4j](https://github.com/NeQuissimus/zio-slf4j) — Referentially transparent logging with slf4j +- [zio-slick](https://github.com/rleibman/zio-slick) — Bridge library between ZIO and Slick Functional Relational Mapping Library +- [zio-test-akka-http](https://github.com/senia-psm/zio-test-akka-http) — Akka-HTTP Route TestKit for zio-test If you know a useful library that has first-class ZIO support, please consider [submitting a pull request](https://github.com/zio/zio/pulls) to add it to this list. diff --git a/docs/resources/ecosystem/compatible.md b/docs/resources/ecosystem/compatible.md index 2740af5d1d24..e348838aa280 100644 --- a/docs/resources/ecosystem/compatible.md +++ b/docs/resources/ecosystem/compatible.md @@ -5,11 +5,11 @@ title: "ZIO Compatible Libraries" List of ZIO compatible libraries: -- [d4s](https://github.com/PlayQ/d4s): "Dynamo DB Database done Scala way". A library that allows accessing the DynamoDB in a purely functional way -- [elastic4s](https://github.com/sksamuel/elastic4s): Elasticsearch Scala Client - Reactive, Non Blocking, Type Safe, HTTP Client -- [neotypes](https://github.com/neotypes/neotypes): A Scala lightweight, type-safe & asynchronous driver for neo4j -- [scanamo](https://github.com/scanamo/scanamo): Simpler DynamoDB access for Scala -- [sttp](https://github.com/softwaremill/sttp): The Scala HTTP client you always wanted! +- [d4s](https://github.com/PlayQ/d4s) — "Dynamo DB Database done Scala way". A library that allows accessing the DynamoDB in a purely functional way +- [elastic4s](https://github.com/sksamuel/elastic4s) — Elasticsearch Scala Client - Reactive, Non Blocking, Type Safe, HTTP Client +- [neotypes](https://github.com/neotypes/neotypes) — A Scala lightweight, type-safe & asynchronous driver for neo4j +- [scanamo](https://github.com/scanamo/scanamo) — Simpler DynamoDB access for Scala +- [sttp](https://github.com/softwaremill/sttp) — The Scala HTTP client you always wanted! - [doobie](https://github.com/tpolecat/doobie) — Functional JDBC layer for Scala. - [fs2](https://github.com/typelevel/fs2) — Compositional, streaming I/O library for Scala - [http4s](https://github.com/http4s/http4s) — A minimal, idiomatic Scala interface for HTTP diff --git a/docs/resources/ecosystem/officials.md b/docs/resources/ecosystem/officials.md index 7ac5541b86d6..2f9224125d6d 100644 --- a/docs/resources/ecosystem/officials.md +++ b/docs/resources/ecosystem/officials.md @@ -5,13 +5,13 @@ title: "Official ZIO Libraries" These libraries are hosted in the [ZIO organization](https://github.com/zio/) on Github, and are generally maintained by core contributors to ZIO. -- [ZIO Actors](https://github.com/zio/zio-actors): A high-performance, purely-functional library for building, composing, and supervising typed actors based on ZIO -- [ZIO Akka Cluster](https://github.com/zio/zio-akka-cluster): A ZIO wrapper for Akka Cluster -- [ZIO Config](https://github.com/zio/zio-config): A ZIO based configuration parsing library -- [ZIO Web](https://github.com/zio/zio-web): A ZIO-powered HTTP server and client -- [ZIO Kafka](https://github.com/zio/zio-kafka): A Kafka client for ZIO and ZIO Streams -- [ZIO Keeper](https://github.com/zio/zio-keeper): A functional library for consistent replication of metadata across dynamic clusters -- [ZIO Logging](https://github.com/zio/zio-logging): An environmental effect for adding logging into any ZIO application, with choice of pluggable back-ends -- [ZIO NIO](https://github.com/zio/zio-nio): A performant, purely-functional, low-level, and unopinionated wrapper around Java NIO functionality -- [ZIO SQS](https://github.com/zio/zio-sqs): A ZIO-powered client for AWS SQS -- [ZIO Telemetry](https://github.com/zio/zio-telemetry): A ZIO-powered OpenTelemetry library +- [ZIO Actors](https://github.com/zio/zio-actors) — A high-performance, purely-functional library for building, composing, and supervising typed actors based on ZIO +- [ZIO Akka Cluster](https://github.com/zio/zio-akka-cluster) — A ZIO wrapper for Akka Cluster +- [ZIO Config](https://github.com/zio/zio-config) — A ZIO based configuration parsing library +- [ZIO Web](https://github.com/zio/zio-web) — A ZIO-powered HTTP server and client +- [ZIO Kafka](https://github.com/zio/zio-kafka) — A Kafka client for ZIO and ZIO Streams +- [ZIO Keeper](https://github.com/zio/zio-keeper) — A functional library for consistent replication of metadata across dynamic clusters +- [ZIO Logging](https://github.com/zio/zio-logging) — An environmental effect for adding logging into any ZIO application, with choice of pluggable back-ends +- [ZIO NIO](https://github.com/zio/zio-nio) — A performant, purely-functional, low-level, and unopinionated wrapper around Java NIO functionality +- [ZIO SQS](https://github.com/zio/zio-sqs) — A ZIO-powered client for AWS SQS +- [ZIO Telemetry](https://github.com/zio/zio-telemetry) — A ZIO-powered OpenTelemetry library diff --git a/docs/resources/ecosystem/templates.md b/docs/resources/ecosystem/templates.md index 46363a2e91a7..8e580ea96deb 100644 --- a/docs/resources/ecosystem/templates.md +++ b/docs/resources/ecosystem/templates.md @@ -5,5 +5,5 @@ title: "Project Templates" List of project starters, bootstrap tools or, templates. -- [zio-akka-quickstart.g8](https://github.com/ScalaConsultants/zio-akka-quickstart.g8): A Giter8 template for a basic Scala application build using ZIO, Akka HTTP and Slick -- [zio-dotty-quickstart.g8](https://github.com/ScalaConsultants/zio-dotty-quickstart.g8): A Giter8 template for a basic Dotty application build using ZIO +- [zio-akka-quickstart.g8](https://github.com/ScalaConsultants/zio-akka-quickstart.g8) — A Giter8 template for a basic Scala application build using ZIO, Akka HTTP and Slick +- [zio-dotty-quickstart.g8](https://github.com/ScalaConsultants/zio-dotty-quickstart.g8) — A Giter8 template for a basic Dotty application build using ZIO diff --git a/docs/resources/learning/projectsusingzio.md b/docs/resources/learning/projectsusingzio.md index 1e48d7154629..652c050b5a27 100644 --- a/docs/resources/learning/projectsusingzio.md +++ b/docs/resources/learning/projectsusingzio.md @@ -3,7 +3,7 @@ id: poweredbyzio title: "Projects using ZIO" --- -- [Rudder](https://github.com/normation/rudder): an example about how to manage error ADT in several sub-projects and specialized sub-domains, and how one can gradually contextualize error messages in domain layers. Uses queues, brackets, interop with Java, and historical code. See [context and references](https://issues.rudder.io/issues/14870). -- [ZIO AI Platform Backend](https://github.com/Clover-Group/zio_front): Clover Group AI Platform backend, which employs ZIO, Doobie, http4s and Kafka . -- [Polynote](https://github.com/polynote/polynote): a new, polyglot notebook with first-class Scala support, Apache Spark integration, multi-language interoperability including Scala, Python, and SQL, as-you-type autocomplete, and more. -- [Blended ZIO](https://blended-zio.github.io/blended-zio/): A sample project migrating a largely untyped, actor based integration framework to ZIO. +- [Rudder](https://github.com/normation/rudder) — an example about how to manage error ADT in several sub-projects and specialized sub-domains, and how one can gradually contextualize error messages in domain layers. Uses queues, brackets, interop with Java, and historical code. See [context and references](https://issues.rudder.io/issues/14870). +- [ZIO AI Platform Backend](https://github.com/Clover-Group/zio_front) — Clover Group AI Platform backend, which employs ZIO, Doobie, http4s and Kafka . +- [Polynote](https://github.com/polynote/polynote) — a new, polyglot notebook with first-class Scala support, Apache Spark integration, multi-language interoperability including Scala, Python, and SQL, as-you-type autocomplete, and more. +- [Blended ZIO](https://blended-zio.github.io/blended-zio/) — A sample project migrating a largely untyped, actor based integration framework to ZIO. From b7f693043bd7caa473807c0134fd4d435d595c95 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 16:00:44 +0430 Subject: [PATCH 18/36] categorize articles. --- docs/resources/learning/articles.md | 87 ++++++++++++++++++----------- 1 file changed, 55 insertions(+), 32 deletions(-) diff --git a/docs/resources/learning/articles.md b/docs/resources/learning/articles.md index adf70db9016f..878498f7367b 100644 --- a/docs/resources/learning/articles.md +++ b/docs/resources/learning/articles.md @@ -5,48 +5,71 @@ title: "Articles" _These articles reflect the state of ZIO at the time of their publication. The code samples might be outdated, considering ZIO was early in development at the time they were written. However, the concepts are still relevant._ -- [Streaming microservices with ZIO and Kafka](https://scalac.io/streaming-microservices-with-zio-and-kafka/) by Aleksandar Skrbic (February 2021) -- [Introduction to ZIO Actors](https://www.softinio.com/post/introduction-to-zio-actors/) by [Salar Rahmanian](https://www.softinio.com) (November 2020) -- [Playing with ZIO Streams and JMS](https://blended-zio.github.io/blended-zio/blog/zio-streams-jms) by Andreas Gies (October 2020) +## ZIO Core +- [Beautiful, Simple, Testable Functional Effects for Scala](http://degoes.net/articles/zio-environment) (introducing ZIO Environment) by John De Goes (February 2019) +- [ZIO & Cats Effect: A Match Made in Heaven](http://degoes.net/articles/zio-cats-effect) by John De Goes (April 2019) +- [Thread Pool Best Practices with ZIO](http://degoes.net/articles/zio-threads) by John De Goes (January 2019) +- [Bifunctor IO: A Step Away from Dynamically-Typed Error Handling](http://degoes.net/articles/bifunctor-io) by John De Goes (May 2018) +- [Wrapping impure code with ZIO](https://medium.com/@ghostdogpr/wrapping-impure-code-with-zio-9265c219e2e) by Pierre Ricadat (July 2019) +- [Thread shifting in cats-effect and ZIO](https://blog.softwaremill.com/thread-shifting-in-cats-effect-and-zio-9c184708067b) by Adam Warski (June 2019) +- [Performant Functional Programming to the Max with ZIO](https://cloudmark.github.io/A-Journey-To-Zio/) by Mark Galea (May 2019) + +## Patterns and Best Practices +- [5 pitfalls to avoid when starting to work with ZIO](https://medium.com/wix-engineering/5-pitfalls-to-avoid-when-starting-to-work-with-zio-adefdc7d2d5c) by Natan Silnitsky (Jan 2020) - [Processing ZIO effects through a pipeline](https://medium.com/@svroonland/processing-zio-effects-through-a-pipeline-c469e28dff62) (September 2020) -- [Lessons Learned From Being a ZIO Contributor](https://www.softinio.com/post/lessons-learned-from-being-a-zio-contributor/) by [Salar Rahmanian](https://www.softinio.com) (September 2020) -- [uzhttp + sttp for light-weight http and websockets](https://timpigden.github.io/_pages/zio-uzhttp-sttp/uzhttp-sttp.html) updated for 1.0.1 by Tim Pigden (August 2020) -- [Streaming all the way with ZIO, Doobie, Quill, http4s and fs2](https://juliano-alves.com/2020/06/15/streaming-all-the-way-zio-doobie-quill-http4s-fs2/) by Juliano Alves (June 2020) -- [Building a cool CLI with Decline for my ZIO App](https://medium.com/@pascal.mengelt/building-a-cool-cli-with-decline-for-my-zio-app-80e095b2899a) by Pascal Mengelt (May 2020) -- [Building the Death Star with ZIO Stream](https://juliano-alves.com/2020/05/04/deathstar-zio-stream/) by Juliano Alves (May 2020) -- [Effective testing with ZIO Test (RC18)](https://scala.monster/zio-test/) by Pavels Sisojevs (April 2020) -- [ZIO with http4s, Auth, Codecs and zio-tests (RC18)](https://timpigden.github.io/_pages/zio-http4s/intro.html) by Tim Pigden (April 2020) -- [ZIO + Http4s: a simple API client](https://juliano-alves.com/2020/04/20/zio-http4s-a-simple-api-client/) by Juliano Alves (April 2020) + +## ZIO STM - [How to write a concurrent LRU cache with ZIO STM](https://scalac.io/how-to-write-a-completely-lock-free-concurrent-lru-cache-with-zio-stm/) by Jorge Vasquez (March 2020) +- [Exploring the STM functionality in ZIO](https://freskog.github.io/blog/2019/05/30/explore-zio-stm/) by Fredrik Skogberg (May 2019) + +## Testing +- [Testing Incrementally with ZIO Environment](http://degoes.net/articles/testable-zio) by John De Goes (March 2019) +- [Effective testing with ZIO Test (RC18)](https://scala.monster/zio-test/) by Pavels Sisojevs (April 2020) +- [Integration Testing](https://blended-zio.github.io/blended-zio/blog/integration-testing) - [Testing background process with ZIO](https://www.rudder.io/blog/testing-background-process-zio/) by François Armand (March 2020) +- [Effective testing with ZIO Test (RC17)](https://scala.monster/zio-test-old/) by Pavels Sisojevs (January 2020) +- [Speeding up time with ZIO TestClock](https://timpigden.github.io/_pages/zio-streams/SpeedingUpTime.html) by Tim Pigden (October 2019) + +## ZIO Streams +- [ZIO Streams and JMS](https://blended-zio.github.io/blended-zio/blog/zio-streams-jms) by Andreas Gies (October 2020) +- [Building the Death Star with ZIO Stream](https://juliano-alves.com/2020/05/04/deathstar-zio-stream/) by Juliano Alves (May 2020) +- [Simulating IoT Events with ZIO Streams](https://timpigden.github.io/_pages/zio-streams/GeneratingChillEvents.html) by Tim Pigden (November 2019) + +## ZIO Module Pattern - [Example of ZLayers being used in combination](https://timpigden.github.io/_pages/zlayer/Examples.html) by Tim Pigden (March 2020) - [From idea to product with ZLayer](https://scala.monster/welcome-zio/) by Pavels Sisojevs (March 2020) -- [Spring to ZIO 101 - ZIO CRUD](https://adrianfilip.com/2020/03/15/spring-to-zio-101/) by Adrian Filip (March 2020) - [What are the benefits of the ZIO modules with ZLayers](https://medium.com/@pascal.mengelt/what-are-the-benefits-of-the-zio-modules-with-zlayers-3bf6cc064a9b) by Pascal Mengelt (March 2020) -- [Effective testing with ZIO Test (RC17)](https://scala.monster/zio-test-old/) by Pavels Sisojevs (January 2020) -- [Implement your future with ZIO](https://scala.monster/welcome-zio-old/) by Pavels Sisojevs (December 2019) - [Decouple the Program from its Implementation with ZIO modules.](https://medium.com/@pascal.mengelt/decouple-the-program-from-its-implementation-with-zio-modules-d9b8713d502e) by Pascal Mengelt (December 2019) -- [How to write a command line application with ZIO?](https://scalac.io/write-command-line-application-with-zio/) by Piotr Gołębiewski (November 2019) -- [What can ZIO do for me? A Long Polling example with sttp.](https://medium.com/@pascal.mengelt/what-can-zio-do-for-me-32281e4e8b16) by Pascal Mengelt (November 2019) -- [Simulating IoT Events with ZIO Streams](https://timpigden.github.io/_pages/zio-streams/GeneratingChillEvents.html) by Tim Pigden (November 2019) -- [Speeding up time with ZIO TestClock](https://timpigden.github.io/_pages/zio-streams/SpeedingUpTime.html) by Tim Pigden (October 2019) - [Functional dependency injection in Scala using ZIO environments](https://blog.jdriven.com/2019/10/functional-dependency-injection-in-scala-using-zio-environments/) by Chiel van de Steeg (October 2019) + +## ZIO Libraries +- [Introduction to ZIO Actors](https://www.softinio.com/post/introduction-to-zio-actors/) by [Salar Rahmanian](https://www.softinio.com) (November 2020) + +## ZIO Use Cases +- [Implement your future with ZIO](https://scala.monster/welcome-zio-old/) by Pavels Sisojevs (December 2019) +- [How to write a command line application with ZIO?](https://scalac.io/write-command-line-application-with-zio/) by Piotr Gołębiewski (November 2019) +- [Building the Hangman Game using ScalaZ ZIO](https://abhsrivastava.github.io/2018/11/03/Hangman-Game-Using-ZIO/) by Abhishek Srivastava (November 2018) +- [Elevator Control System using ZIO](https://medium.com/@wiemzin/elevator-control-system-using-zio-c718ae423c58) by Wiem Zine El Abidine (September 2018) +- [Spring to ZIO 101 - ZIO CRUD](https://adrianfilip.com/2020/03/15/spring-to-zio-101/) by Adrian Filip (March 2020) +- [Hacker News API Part 5](http://justinhj.github.io/2019/04/07/hacker-news-api-5.html) by Justin Heyes-Jones (April 2019) + +## Integration with Other Libraries - [Making ZIO, Akka and Slick play together nicely](https://scalac.io/making-zio-akka-slick-play-together-nicely-part-1-zio-and-slick/) by Jakub Czuchnowski (August 2019) -- [Wrapping impure code with ZIO](https://medium.com/@ghostdogpr/wrapping-impure-code-with-zio-9265c219e2e) by Pierre Ricadat (July 2019) +- [ZIO + Http4s: a simple API client](https://juliano-alves.com/2020/04/20/zio-http4s-a-simple-api-client/) by Juliano Alves (April 2020) - [Combining ZIO and Akka to enable distributed FP in Scala](https://medium.com/@ghostdogpr/combining-zio-and-akka-to-enable-distributed-fp-in-scala-61ffb81e3283) by Pierre Ricadat (July 2019) -- [tAPIr’s Endpoint meets ZIO’s IO](https://blog.softwaremill.com/tapirs-endpoint-meets-zio-s-io-3278099c5e10) by Adam Warski (July 2019) - [ZIO with http4s and doobie](https://medium.com/@wiemzin/zio-with-http4s-and-doobie-952fba51d089) by Wiem Zine El Abidine (June 2019) -- [Thread shifting in cats-effect and ZIO](https://blog.softwaremill.com/thread-shifting-in-cats-effect-and-zio-9c184708067b) by Adam Warski (June 2019) -- [Exploring the STM functionality in ZIO](https://freskog.github.io/blog/2019/05/30/explore-zio-stm/) by Fredrik Skogberg (May 2019) -- [Performant Functional Programming to the Max with ZIO](https://cloudmark.github.io/A-Journey-To-Zio/) by Mark Galea (May 2019) - [Using 47 Degree's Fetch library with ZIO](http://justinhj.github.io/2019/05/05/using-47degs-fetch-with-zio.html) by Justin Heyes-Jones (May 2019) -- [ZIO & Cats Effect: A Match Made in Heaven](http://degoes.net/articles/zio-cats-effect) by John De Goes (April 2019) -- [Hacker News API Part 5](http://justinhj.github.io/2019/04/07/hacker-news-api-5.html) by Justin Heyes-Jones (April 2019) -- [Testing Incrementally with ZIO Environment](http://degoes.net/articles/testable-zio) by John De Goes (March 2019) -- [Beautiful, Simple, Testable Functional Effects for Scala](http://degoes.net/articles/zio-environment) (introducing ZIO Environment) by John De Goes (February 2019) -- [Thread Pool Best Practices with ZIO](http://degoes.net/articles/zio-threads) by John De Goes (January 2019) -- [Building the Hangman Game using ScalaZ ZIO](https://abhsrivastava.github.io/2018/11/03/Hangman-Game-Using-ZIO/) by Abhishek Srivastava (November 2018) -- [Elevator Control System using ZIO](https://medium.com/@wiemzin/elevator-control-system-using-zio-c718ae423c58) by Wiem Zine El Abidine (September 2018) +- [What can ZIO do for me? A Long Polling example with sttp.](https://medium.com/@pascal.mengelt/what-can-zio-do-for-me-32281e4e8b16) by Pascal Mengelt (November 2019) +- [uzhttp + sttp for light-weight http and websockets](https://timpigden.github.io/_pages/zio-uzhttp-sttp/uzhttp-sttp.html) updated for 1.0.1 by Tim Pigden (August 2020) +- [Streaming all the way with ZIO, Doobie, Quill, http4s and fs2](https://juliano-alves.com/2020/06/15/streaming-all-the-way-zio-doobie-quill-http4s-fs2/) by Juliano Alves (June 2020) +- [ZIO with http4s, Auth, Codecs and zio-tests (RC18)](https://timpigden.github.io/_pages/zio-http4s/intro.html) by Tim Pigden (April 2020) +- [Building a cool CLI with Decline for my ZIO App](https://medium.com/@pascal.mengelt/building-a-cool-cli-with-decline-for-my-zio-app-80e095b2899a) by Pascal Mengelt (May 2020) +- [Streaming microservices with ZIO and Kafka](https://scalac.io/streaming-microservices-with-zio-and-kafka/) by Aleksandar Skrbic (February 2021) +- [tAPIr’s Endpoint meets ZIO’s IO](https://blog.softwaremill.com/tapirs-endpoint-meets-zio-s-io-3278099c5e10) by Adam Warski (July 2019) + +## Contribution +- [Lessons Learned From Being a ZIO Contributor](https://www.softinio.com/post/lessons-learned-from-being-a-zio-contributor/) by [Salar Rahmanian](https://www.softinio.com) (September 2020) + +## Benchmarking and Comparison - [Scalaz 8 IO vs Akka (typed) Actors vs Monix (part 1)](https://blog.softwaremill.com/scalaz-8-io-vs-akka-typed-actors-vs-monix-part-1-5672657169e1) + [part 2](https://blog.softwaremill.com/akka-vs-zio-vs-monix-part-2-communication-9ce7261aa08c) + [part 3](https://blog.softwaremill.com/supervision-error-handling-in-zio-akka-and-monix-part-3-series-summary-abe75f964c2a) by Adam Warski (June 2018) -- [Bifunctor IO: A Step Away from Dynamically-Typed Error Handling](http://degoes.net/articles/bifunctor-io) by John De Goes (May 2018) -- [5 pitfalls to avoid when starting to work with ZIO](https://medium.com/wix-engineering/5-pitfalls-to-avoid-when-starting-to-work-with-zio-adefdc7d2d5c) by Natan Silnitsky (Jan 2020) +- [Benchmarking Functional Error Handling in Scala](https://www.iteratorshq.com/blog/benchmarking-functional-error-handling-in-scala/) by Marcin Rzeźnicki \ No newline at end of file From 7193987567f521906a063267d1d1b334ff406868 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 16:49:49 +0430 Subject: [PATCH 19/36] categorize videos. --- docs/resources/learning/videos.md | 51 +++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/docs/resources/learning/videos.md b/docs/resources/learning/videos.md index 5d2422170f54..c56c253f7963 100644 --- a/docs/resources/learning/videos.md +++ b/docs/resources/learning/videos.md @@ -3,31 +3,50 @@ id: videos title: "Videos" --- -- [Acting Lessons for Scala Engineers with Akka and ZIO](https://www.youtube.com/watch?v=AQXBlbkf9wc) by [Salar Rahmanian](https://wwww.softinio.com) (November 2020) -- [Redis Streams with ZIO](https://youtu.be/jJnco6sMZQY) by [Leszek Gruchała](https://twitter.com/leszekgruchala) (October 2020) -- [Declarative Concurrency with ZIO STM](https://www.youtube.com/watch?v=MEH7hQmGK5M) by Dejan Mijic (June 2020) +## Functional Programming - [FP to the Max](https://www.youtube.com/watch?v=sxudIMiOo68) by John De Goes (July 2018) -- [Modern Data Driven Applications with ZIO Streams](https://youtu.be/bbss7elSfxs) by Itamar Ravid (December 2019) -- Systematic error management in application - We ported Rudder to ZIO: [video in French](https://www.youtube.com/watch?v=q0PlcgR5M1Q), [slides in English](https://speakerdeck.com/fanf42/systematic-error-management-we-ported-rudder-to-zio) by François Armand (Scala.io, October 2019) +- [FP to the Min](https://www.youtube.com/watch?v=mrHphQT4RpU) by John De Goes (July 2020) + +## ZIO Core +- [The Death of Tagless Final](https://www.youtube.com/watch?v=p98W4bUtbO8) by John De Goes (February 2019) +- [A Tour of ZIO](https://www.youtube.com/watch?v=TWdC7DhvD8M) by John De Goes (January 2020) - [Upgrade Your Future](https://www.youtube.com/watch?v=USgfku1h7Hw) by John De Goes (September 2019) - [One Monad to Rule Them All](https://www.youtube.com/watch?v=POUEz8XHMhE) by John De Goes (August 2019) - [Functional Concurrency in Scala with ZIO](https://www.youtube.com/watch?v=m5nas4Hndqo) by Itamar Ravid (June 2019) -- [Error Management: Future vs ZIO](https://www.youtube.com/watch?v=mGxcaQs3JWI) by John De Goes and Kai (May 2019), [slide](https://www.slideshare.net/jdegoes/error-management-future-vs-zio) -- [Atomically { Delete Your Actors }](https://www.youtube.com/watch?v=d6WWmia0BPM) by John De Goes and Wiem Zine El Abidine (April 2019) - [Thinking Functionally](https://www.youtube.com/watch?v=-KA3BSdqYug) by John De Goes (March 2019) - [Tour of ZIO](https://www.youtube.com/watch?v=5s0GOA3WQnY&t=1405s) by Oleksandra Holubitska (March 2019) -- [The Death of Tagless Final](https://skillsmatter.com/skillscasts/13247-scala-matters) by John De Goes (February 2019) -- [ZIO Queue](https://www.youtube.com/watch?v=lBYkLc-j7Vo) by Wiem Zine El Abidine (January 2019) -- [ZIO Stream: Rebirth](https://www.youtube.com/watch?v=mLJYODobz44&t=15s) by John De Goes and Itamar Ravid (November 2018) -- [ZIO Schedule: Conquering Flakiness and Recurrence with Pure Functional Programming](https://www.youtube.com/watch?v=onQSHiafAY8&t=1s) by John De Goes (October 2018) - [ZIO: Next-Generation Effects in Scala](https://www.youtube.com/watch?v=mkSHhsJXjdc&t=6s) by John De Goes (October 2018) -- [ZIO Queue: A new Queue for a new Era](https://www.youtube.com/watch?v=8JLprl34xEw&t=2437s) by John De Goes (September 2018) +- [Functional Effects in ZIO](https://www.youtube.com/watch?v=4EeL8-chAR8) by Wiem Zine El Abidine + +## Error Management +- [Error Management: Future vs ZIO](https://www.youtube.com/watch?v=mGxcaQs3JWI) by John De Goes and Kai (May 2019), [slide](https://www.slideshare.net/jdegoes/error-management-future-vs-zio) +- Systematic error management in application - We ported Rudder to ZIO: [video in French](https://www.youtube.com/watch?v=q0PlcgR5M1Q), [slides in English](https://speakerdeck.com/fanf42/systematic-error-management-we-ported-rudder-to-zio) by François Armand (Scala.io, October 2019) + +## ZIO Module Pattern - [ZLayers by example](https://www.youtube.com/watch?v=u5IrfkAo6nk) by Wiem Zine El Abidine (December 2020) - [ZIO inception: Journey through layers and intersection types](https://www.youtube.com/watch?v=vNQFlq1SvaE) by Vladimir Pavkin (July 2020) -- [A Tour of ZIO](https://www.youtube.com/watch?v=TWdC7DhvD8M) by John De Goes (January 2020) -### Scala in the City Conference by Signify Technologies, May 2020 +## ZIO Schedule +- [ZIO Schedule: Conquering Flakiness and Recurrence with Pure Functional Programming](https://www.youtube.com/watch?v=onQSHiafAY8&t=1s) by John De Goes (October 2018) + +## ZIO Concurrency Primitives +- [Atomically { Delete Your Actors }](https://www.youtube.com/watch?v=d6WWmia0BPM) by John De Goes and Wiem Zine El Abidine (April 2019) +- [ZIO Queue](https://www.youtube.com/watch?v=lBYkLc-j7Vo) by Wiem Zine El Abidine (January 2019) +- [ZIO Queue: A new Queue for a new Era](https://www.youtube.com/watch?v=8JLprl34xEw&t=2437s) by John De Goes (September 2018) + +## ZIO STM +- [Declarative Concurrency with ZIO STM](https://www.youtube.com/watch?v=MEH7hQmGK5M) by Dejan Mijic (June 2020) + +## ZIO Test - [0 to 100 with ZIO Test](https://www.youtube.com/watch?v=qDFfVinjDPQ) by Adam Fraser + +## ZIO Streams +- [Modern Data Driven Applications with ZIO Streams](https://youtu.be/bbss7elSfxs) by Itamar Ravid (December 2019) +- [ZIO Stream: Rebirth](https://www.youtube.com/watch?v=mLJYODobz44&t=15s) by John De Goes and Itamar Ravid (November 2018) - [The Joys of (Z)Streams](https://www.youtube.com/watch?v=XIIX2YSg7M0) by Itamar Ravid -- [FP to the Min](https://www.youtube.com/watch?v=mrHphQT4RpU) by John De Goes -- [Functional Effects in ZIO](https://www.youtube.com/watch?v=4EeL8-chAR8) by Wiem Zine El Abidine + +## ZIO Actors +- [Acting Lessons for Scala Engineers with Akka and ZIO](https://www.youtube.com/watch?v=AQXBlbkf9wc) by [Salar Rahmanian](https://wwww.softinio.com) (November 2020) + +## Others +- [Redis Streams with ZIO](https://youtu.be/jJnco6sMZQY) by [Leszek Gruchała](https://twitter.com/leszekgruchala) (October 2020) From 9f75724f39877d0fb4adb5ef57dba2b2ea3799df Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 17:57:36 +0430 Subject: [PATCH 20/36] enable edit button for each page. --- website/siteConfig.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/website/siteConfig.js b/website/siteConfig.js index 83659116e44d..e57c5916190f 100644 --- a/website/siteConfig.js +++ b/website/siteConfig.js @@ -8,6 +8,8 @@ // See https://docusaurus.io/docs/site-config for all the possible // site configuration options. +const repoUrl = "https://github.com/zio/zio"; + // List of projects/orgs using your project for the users page. const users = [ /* @@ -114,6 +116,9 @@ const siteConfig = { }, docsSideNavCollapsible: true, + + editUrl: `${repoUrl}/edit/master/docs/`, + }; module.exports = siteConfig; From 3fac2cd6948f47dd74f365524ffd364c7009d7e0 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 18:28:23 +0430 Subject: [PATCH 21/36] remove scalaz 8 interop page. --- docs/interop/scalaz8.md | 6 ------ website/sidebars.json | 1 - 2 files changed, 7 deletions(-) delete mode 100644 docs/interop/scalaz8.md diff --git a/docs/interop/scalaz8.md b/docs/interop/scalaz8.md deleted file mode 100644 index 5ac430c26645..000000000000 --- a/docs/interop/scalaz8.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -id: interop_scalaz_8 -title: "Scalaz 8" ---- - -Coming soon... diff --git a/website/sidebars.json b/website/sidebars.json index 718d03f0dba1..453fa34039f3 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -97,7 +97,6 @@ "interop/interop_javascript", "interop/interop_monix", "interop/interop_scalaz7x", - "interop/interop_scalaz_8", "interop/interop_reactivestreams", "interop/interop_twitter" ] From 2f02ab52ce9ad9328e3254106d9d1e94328e7d5d Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 19:27:15 +0430 Subject: [PATCH 22/36] move interop section into howto section. --- docs/{ => howto}/interop/catseffect.md | 2 +- docs/{ => howto}/interop/future.md | 2 +- docs/{ => howto}/interop/java.md | 2 +- docs/{ => howto}/interop/javascript.md | 2 +- docs/{ => howto}/interop/monix.md | 2 +- docs/{ => howto}/interop/reactivestreams.md | 2 +- docs/{ => howto}/interop/scalaz7x.md | 2 +- docs/{ => howto}/interop/twitter.md | 2 +- website/sidebars.json | 23 +++++++++------------ website/siteConfig.js | 1 - 10 files changed, 18 insertions(+), 22 deletions(-) rename docs/{ => howto}/interop/catseffect.md (99%) rename docs/{ => howto}/interop/future.md (98%) rename docs/{ => howto}/interop/java.md (99%) rename docs/{ => howto}/interop/javascript.md (98%) rename docs/{ => howto}/interop/monix.md (99%) rename docs/{ => howto}/interop/reactivestreams.md (98%) rename docs/{ => howto}/interop/scalaz7x.md (98%) rename docs/{ => howto}/interop/twitter.md (97%) diff --git a/docs/interop/catseffect.md b/docs/howto/interop/catseffect.md similarity index 99% rename from docs/interop/catseffect.md rename to docs/howto/interop/catseffect.md index be6fed95854c..68a3e05e84b1 100644 --- a/docs/interop/catseffect.md +++ b/docs/howto/interop/catseffect.md @@ -1,5 +1,5 @@ --- -id: interop_catseffect +id: catseffect title: "Cats Effect" --- diff --git a/docs/interop/future.md b/docs/howto/interop/future.md similarity index 98% rename from docs/interop/future.md rename to docs/howto/interop/future.md index a8eadf2bea50..cc491ab95a7e 100644 --- a/docs/interop/future.md +++ b/docs/howto/interop/future.md @@ -1,5 +1,5 @@ --- -id: interop_future +id: future title: "Future" --- diff --git a/docs/interop/java.md b/docs/howto/interop/java.md similarity index 99% rename from docs/interop/java.md rename to docs/howto/interop/java.md index ee48d6092c83..19715ff1d015 100644 --- a/docs/interop/java.md +++ b/docs/howto/interop/java.md @@ -1,5 +1,5 @@ --- -id: interop_java +id: java title: "Java" --- diff --git a/docs/interop/javascript.md b/docs/howto/interop/javascript.md similarity index 98% rename from docs/interop/javascript.md rename to docs/howto/interop/javascript.md index a1b72addbfe3..dba48b12204c 100644 --- a/docs/interop/javascript.md +++ b/docs/howto/interop/javascript.md @@ -1,5 +1,5 @@ --- -id: interop_javascript +id: javascript title: "JavaScript" --- diff --git a/docs/interop/monix.md b/docs/howto/interop/monix.md similarity index 99% rename from docs/interop/monix.md rename to docs/howto/interop/monix.md index a2a0eb54ad49..db976b18df75 100644 --- a/docs/interop/monix.md +++ b/docs/howto/interop/monix.md @@ -1,5 +1,5 @@ --- -id: interop_monix +id: monix title: "Monix" --- diff --git a/docs/interop/reactivestreams.md b/docs/howto/interop/reactivestreams.md similarity index 98% rename from docs/interop/reactivestreams.md rename to docs/howto/interop/reactivestreams.md index 8f51e0b996f9..b23e2a1c2b4e 100644 --- a/docs/interop/reactivestreams.md +++ b/docs/howto/interop/reactivestreams.md @@ -1,5 +1,5 @@ --- -id: interop_reactivestreams +id: reactivestreams title: "Reactive Streams" --- diff --git a/docs/interop/scalaz7x.md b/docs/howto/interop/scalaz7x.md similarity index 98% rename from docs/interop/scalaz7x.md rename to docs/howto/interop/scalaz7x.md index 40476e0e272f..2713e6c01c55 100644 --- a/docs/interop/scalaz7x.md +++ b/docs/howto/interop/scalaz7x.md @@ -1,5 +1,5 @@ --- -id: interop_scalaz7x +id: scalaz7x title: "Scalaz 7.x" --- diff --git a/docs/interop/twitter.md b/docs/howto/interop/twitter.md similarity index 97% rename from docs/interop/twitter.md rename to docs/howto/interop/twitter.md index 5437f673ca0f..bb22e4db80e1 100644 --- a/docs/interop/twitter.md +++ b/docs/howto/interop/twitter.md @@ -1,5 +1,5 @@ --- -id: interop_twitter +id: twitter title: "Twitter" --- diff --git a/website/sidebars.json b/website/sidebars.json index 453fa34039f3..fbc0fdbb153d 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -88,19 +88,6 @@ "services/system" ] }, - "interop-sidebar": { - "Interop": [ - "interop/interop_index", - "interop/interop_catseffect", - "interop/interop_future", - "interop/interop_java", - "interop/interop_javascript", - "interop/interop_monix", - "interop/interop_scalaz7x", - "interop/interop_reactivestreams", - "interop/interop_twitter" - ] - }, "usecases-sidebar": { "Use Cases": [ "usecases/usecases_index", @@ -125,6 +112,16 @@ "howto/howto_access_system_information", "howto/howto_macros", "howto/migrating_from_monix" + ], + "Interop": [ + "howto/interop/catseffect", + "howto/interop/future", + "howto/interop/java", + "howto/interop/javascript", + "howto/interop/monix", + "howto/interop/scalaz7x", + "howto/interop/reactivestreams", + "howto/interop/twitter" ] }, "resources-sidebar": { diff --git a/website/siteConfig.js b/website/siteConfig.js index e57c5916190f..66448afa373c 100644 --- a/website/siteConfig.js +++ b/website/siteConfig.js @@ -38,7 +38,6 @@ const siteConfig = { { doc: 'overview/overview_index', label: 'Overview' }, { doc: 'datatypes/index', label: 'Data Types' }, { doc: 'services/index', label: 'Services' }, - { doc: 'interop/interop_index', label: 'Interop' }, { doc: 'usecases/usecases_index', label: 'Use Cases' }, { doc: 'howto/howto_index', label: 'How to' }, { doc: 'resources/index', label: 'Resources' }, From f4cde51c63d84a65c9f02a255928ee386001f7ac Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 19:53:19 +0430 Subject: [PATCH 23/36] remove summary page of learning section. --- docs/resources/learning/index.md | 16 ---------------- website/sidebars.json | 1 - 2 files changed, 17 deletions(-) delete mode 100644 docs/resources/learning/index.md diff --git a/docs/resources/learning/index.md b/docs/resources/learning/index.md deleted file mode 100644 index 496c9ac992f9..000000000000 --- a/docs/resources/learning/index.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -id: index -title: "Summary" ---- - -If you find a new great talk, resource, slides or project, related to ZIO, consider adding to the list with your PR. - -- [Articles](articles.md) -- [Talks](videos.md) -- [Cookbooks](cookbooks.md) -- [Cheat Sheets](cheatsheets.md) -- [Sample Projects](sampleprojects.md) -- [Project using ZIO](projectsusingzio.md) - -## Support -- [Official Discord Server](https://discord.gg/2ccFBr4) diff --git a/website/sidebars.json b/website/sidebars.json index fbc0fdbb153d..45fc7d5b0a6e 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -129,7 +129,6 @@ "resources/index" ], "Learning": [ - "resources/learning/index", "resources/learning/articles", "resources/learning/videos", "resources/learning/cookbooks", From b513999bd02ffec63c0735deb77291b6cb441f3e Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 20:50:06 +0430 Subject: [PATCH 24/36] create a index page for howto section. --- docs/howto/index.md | 11 ++--------- website/sidebars.json | 2 +- website/siteConfig.js | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/docs/howto/index.md b/docs/howto/index.md index 0cc41e57348b..e365775fb1d2 100644 --- a/docs/howto/index.md +++ b/docs/howto/index.md @@ -1,14 +1,7 @@ --- -id: howto_index +id: index title: "Summary" --- -Here are a few guides for common patterns with ZIO: +Here are a few howto guides for common patterns with ZIO. -- **[Use modules and layers](use_modules_and_layers.md)**: how to structure larger ZIO programs with the help of **ZIO environment**. -- **[Test assertions](test_assertions.md)**: how to use **ZIO Test** assert properties in your code. -- **[Test effects](test_effects.md)**: how to use **ZIO Test** to test effectual programs seamlessly. -- **[Mock services](mock_services.md)**: how to test interactions between services with **mocks**. -- **[Handle errors](handle_errors.md)**: how to deal with **errors** in ZIO (declared errors vs unforeseen defects). -- **[Access system information](system.md)**: how to access **environment variables** and other **system properties** with ZIO. -- **[How to migrate from Monix to ZIO](migrating_from_monix.md)** diff --git a/website/sidebars.json b/website/sidebars.json index 45fc7d5b0a6e..a9ad6fddf05a 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -102,8 +102,8 @@ ] }, "howto-sidebar": { + "Overview": ["howto/index"], "How to": [ - "howto/howto_index", "howto/howto_use_layers", "howto/howto_test_assertions", "howto/howto_test_effects", diff --git a/website/siteConfig.js b/website/siteConfig.js index 66448afa373c..04b5b8a9abcb 100644 --- a/website/siteConfig.js +++ b/website/siteConfig.js @@ -39,7 +39,7 @@ const siteConfig = { { doc: 'datatypes/index', label: 'Data Types' }, { doc: 'services/index', label: 'Services' }, { doc: 'usecases/usecases_index', label: 'Use Cases' }, - { doc: 'howto/howto_index', label: 'How to' }, + { doc: 'howto/index', label: 'How to' }, { doc: 'resources/index', label: 'Resources' }, { doc: 'about/about_index', label: 'About' }, ], From 294ee7c0e3efb79ebcfd49edd823cc501a929a18 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 21:18:46 +0430 Subject: [PATCH 25/36] rename howto pages to be more seo friendly. --- .../{system.md => access-system-information.md} | 4 ++-- .../howto/{handle_errors.md => handle-errors.md} | 4 ++-- docs/howto/{howto_macros.md => howto-macros.md} | 4 ++-- ...ating_from_monix.md => migrate-from-monix.md} | 4 ++-- .../howto/{mock_services.md => mock-services.md} | 8 ++++---- docs/howto/test_effects.md | 4 ++-- ...s_and_layers.md => use-modules-and-layers.md} | 4 ++-- ...test_assertions.md => use-test-assertions.md} | 5 +++++ website/sidebars.json | 16 ++++++++-------- 9 files changed, 29 insertions(+), 24 deletions(-) rename docs/howto/{system.md => access-system-information.md} (90%) rename docs/howto/{handle_errors.md => handle-errors.md} (98%) rename docs/howto/{howto_macros.md => howto-macros.md} (97%) rename docs/howto/{migrating_from_monix.md => migrate-from-monix.md} (97%) rename docs/howto/{mock_services.md => mock-services.md} (99%) rename docs/howto/{use_modules_and_layers.md => use-modules-and-layers.md} (99%) rename docs/howto/{test_assertions.md => use-test-assertions.md} (99%) diff --git a/docs/howto/system.md b/docs/howto/access-system-information.md similarity index 90% rename from docs/howto/system.md rename to docs/howto/access-system-information.md index ef7fd0666950..70ce890499e8 100644 --- a/docs/howto/system.md +++ b/docs/howto/access-system-information.md @@ -1,6 +1,6 @@ --- -id: howto_access_system_information -title: "Access system information" +id: access-system-information +title: "How to Access System Information?" --- Sometimes, environment variables are relevant information to an application. ZIO provides a `system` package to interface with this functionality. diff --git a/docs/howto/handle_errors.md b/docs/howto/handle-errors.md similarity index 98% rename from docs/howto/handle_errors.md rename to docs/howto/handle-errors.md index df6b96cc1e66..5778e41accd6 100644 --- a/docs/howto/handle_errors.md +++ b/docs/howto/handle-errors.md @@ -1,6 +1,6 @@ --- -id: howto_handle_errors -title: "Handle errors" +id: handle-errors +title: "How to Handle Errors?" --- ## Declared Errors vs Unforeseen Defects diff --git a/docs/howto/howto_macros.md b/docs/howto/howto-macros.md similarity index 97% rename from docs/howto/howto_macros.md rename to docs/howto/howto-macros.md index 5515e313961c..131769eb48aa 100644 --- a/docs/howto/howto_macros.md +++ b/docs/howto/howto-macros.md @@ -1,6 +1,6 @@ --- -id: howto_macros -title: "Macros" +id: use-zio-macros +title: "How to use ZIO Macros?" --- ## Scrapping the boilerplate with macros diff --git a/docs/howto/migrating_from_monix.md b/docs/howto/migrate-from-monix.md similarity index 97% rename from docs/howto/migrating_from_monix.md rename to docs/howto/migrate-from-monix.md index 6ea602fc636a..33c27ef6d267 100644 --- a/docs/howto/migrating_from_monix.md +++ b/docs/howto/migrate-from-monix.md @@ -1,6 +1,6 @@ --- -id: migrating_from_monix -title: "How to migrate from Monix to ZIO" +id: migrate-from-monix +title: "How to Migrate from Monix to ZIO?" --- Monix's `Task[A]` can be easily replaced with ZIO's `Task[A]` (an alias for `ZIO[Any, Throwable, A]`). diff --git a/docs/howto/mock_services.md b/docs/howto/mock-services.md similarity index 99% rename from docs/howto/mock_services.md rename to docs/howto/mock-services.md index b384c6f37115..98677040173b 100644 --- a/docs/howto/mock_services.md +++ b/docs/howto/mock-services.md @@ -1,6 +1,6 @@ --- -id: howto_mock_services -title: "Mock services" +id: mock-services +title: "How to Mock Services?" --- ## How to test interactions between services? @@ -476,8 +476,8 @@ You can find more examples in the `examples` and `test-tests` subproject: - [ComposedEmptyMockSpec][link-gh-composed-empty-mock-spec] - [PolyMockSpec][link-gh-poly-mock-spec] -[doc-use-modules-and-layers]: use_modules_and_layers.md -[doc-macros]: howto_macros.md +[doc-use-modules-and-layers]: use-modules-and-layers.md +[doc-macros]: howto-macros.md [link-sls-6.26.1]: https://scala-lang.org/files/archive/spec/2.13/06-expressions.html#value-conversions [link-test-doubles]: https://martinfowler.com/articles/mocksArentStubs.html [link-gh-mock-example-spec]: https://github.com/zio/zio/blob/master/examples/shared/src/test/scala/zio/examples/test/MockExampleSpec.scala diff --git a/docs/howto/test_effects.md b/docs/howto/test_effects.md index 07ec88a3d47a..b0ae17b90d7c 100644 --- a/docs/howto/test_effects.md +++ b/docs/howto/test_effects.md @@ -1,6 +1,6 @@ --- -id: howto_test_effects -title: "Test effects" +id: test-effects +title: "How to Test effects?" --- ## How zio-test was designed diff --git a/docs/howto/use_modules_and_layers.md b/docs/howto/use-modules-and-layers.md similarity index 99% rename from docs/howto/use_modules_and_layers.md rename to docs/howto/use-modules-and-layers.md index 0b29eb9d609b..e013c05f8748 100644 --- a/docs/howto/use_modules_and_layers.md +++ b/docs/howto/use-modules-and-layers.md @@ -1,6 +1,6 @@ --- -id: howto_use_layers -title: "Use modules and layers" +id: use-modules-and-layers +title: "How to Use Modules and Layers?" --- # Unleash ZIO environment with `ZLayer` diff --git a/docs/howto/test_assertions.md b/docs/howto/use-test-assertions.md similarity index 99% rename from docs/howto/test_assertions.md rename to docs/howto/use-test-assertions.md index ad7285a785d3..f76dde4bf701 100644 --- a/docs/howto/test_assertions.md +++ b/docs/howto/use-test-assertions.md @@ -1,3 +1,8 @@ +--- +id: use-test-assertions +title: "How to Use Test Assertions" +--- + Using the `Assertion` type effectively often involves finding the best fitting function for the type of assumptions you would like to verify. diff --git a/website/sidebars.json b/website/sidebars.json index a9ad6fddf05a..376536bbc3eb 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -104,14 +104,14 @@ "howto-sidebar": { "Overview": ["howto/index"], "How to": [ - "howto/howto_use_layers", - "howto/howto_test_assertions", - "howto/howto_test_effects", - "howto/howto_mock_services", - "howto/howto_handle_errors", - "howto/howto_access_system_information", - "howto/howto_macros", - "howto/migrating_from_monix" + "howto/use-modules-and-layers", + "howto/use-test-assertions", + "howto/test-effects", + "howto/mock-services", + "howto/handle-errors", + "howto/access-system-information", + "howto/use-zio-macros", + "howto/migrate-from-monix" ], "Interop": [ "howto/interop/catseffect", From b0735e10f24ae11c32de3b206986a291537f68f0 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 21:25:38 +0430 Subject: [PATCH 26/36] add a separate section for migration in howto section. --- docs/howto/{migrate-from-monix.md => migrate/from-monix.md} | 2 +- website/sidebars.json | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) rename docs/howto/{migrate-from-monix.md => migrate/from-monix.md} (99%) diff --git a/docs/howto/migrate-from-monix.md b/docs/howto/migrate/from-monix.md similarity index 99% rename from docs/howto/migrate-from-monix.md rename to docs/howto/migrate/from-monix.md index 33c27ef6d267..70dc04f3202b 100644 --- a/docs/howto/migrate-from-monix.md +++ b/docs/howto/migrate/from-monix.md @@ -1,5 +1,5 @@ --- -id: migrate-from-monix +id: from-monix title: "How to Migrate from Monix to ZIO?" --- diff --git a/website/sidebars.json b/website/sidebars.json index 376536bbc3eb..b480cfe96eb6 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -110,8 +110,7 @@ "howto/mock-services", "howto/handle-errors", "howto/access-system-information", - "howto/use-zio-macros", - "howto/migrate-from-monix" + "howto/use-zio-macros" ], "Interop": [ "howto/interop/catseffect", @@ -122,6 +121,9 @@ "howto/interop/scalaz7x", "howto/interop/reactivestreams", "howto/interop/twitter" + ], + "Migrate": [ + "howto/migrate/from-monix" ] }, "resources-sidebar": { From 6fac798b9cad6e84a284beb2d2d6f875c68e7bd7 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 21:58:10 +0430 Subject: [PATCH 27/36] make interop urls more seo friendly. --- .../{catseffect.md => with-catseffect.md} | 4 ++-- docs/howto/interop/{future.md => with-future.md} | 4 ++-- docs/howto/interop/{java.md => with-java.md} | 4 ++-- .../{javascript.md => with-javascript.md} | 4 ++-- docs/howto/interop/{monix.md => with-monix.md} | 4 ++-- ...activestreams.md => with-reactive-streams.md} | 4 ++-- .../interop/{scalaz7x.md => with-scalaz-7x.md} | 4 ++-- .../interop/{twitter.md => with-twitter.md} | 4 ++-- website/sidebars.json | 16 ++++++++-------- 9 files changed, 24 insertions(+), 24 deletions(-) rename docs/howto/interop/{catseffect.md => with-catseffect.md} (97%) rename docs/howto/interop/{future.md => with-future.md} (96%) rename docs/howto/interop/{java.md => with-java.md} (98%) rename docs/howto/interop/{javascript.md => with-javascript.md} (96%) rename docs/howto/interop/{monix.md => with-monix.md} (97%) rename docs/howto/interop/{reactivestreams.md => with-reactive-streams.md} (97%) rename docs/howto/interop/{scalaz7x.md => with-scalaz-7x.md} (96%) rename docs/howto/interop/{twitter.md => with-twitter.md} (92%) diff --git a/docs/howto/interop/catseffect.md b/docs/howto/interop/with-catseffect.md similarity index 97% rename from docs/howto/interop/catseffect.md rename to docs/howto/interop/with-catseffect.md index 68a3e05e84b1..63d2de727080 100644 --- a/docs/howto/interop/catseffect.md +++ b/docs/howto/interop/with-catseffect.md @@ -1,6 +1,6 @@ --- -id: catseffect -title: "Cats Effect" +id: with-catseffect +title: "How to Interop with Cats Effect?" --- The `interop-cats` module provides interoperability for the Cats Effect ecosystem. diff --git a/docs/howto/interop/future.md b/docs/howto/interop/with-future.md similarity index 96% rename from docs/howto/interop/future.md rename to docs/howto/interop/with-future.md index cc491ab95a7e..de7a679dd912 100644 --- a/docs/howto/interop/future.md +++ b/docs/howto/interop/with-future.md @@ -1,6 +1,6 @@ --- -id: future -title: "Future" +id: with-future +title: "How to Interop with Future?" --- ## Scala Future diff --git a/docs/howto/interop/java.md b/docs/howto/interop/with-java.md similarity index 98% rename from docs/howto/interop/java.md rename to docs/howto/interop/with-java.md index 19715ff1d015..9261f4c7a452 100644 --- a/docs/howto/interop/java.md +++ b/docs/howto/interop/with-java.md @@ -1,6 +1,6 @@ --- -id: java -title: "Java" +id: with-java +title: "How to Interop with Java?" --- ZIO has full interoperability with foreign Java code. Let me show you how it works and then *BOOM*, tomorrow you can show off your purely functional Java at work. diff --git a/docs/howto/interop/javascript.md b/docs/howto/interop/with-javascript.md similarity index 96% rename from docs/howto/interop/javascript.md rename to docs/howto/interop/with-javascript.md index dba48b12204c..ba7f9ae0b486 100644 --- a/docs/howto/interop/javascript.md +++ b/docs/howto/interop/with-javascript.md @@ -1,6 +1,6 @@ --- -id: javascript -title: "JavaScript" +id: with-javascript +title: "How to Interop with JavaScript?" --- Include ZIO in your Scala.js project by adding the following to your `build.sbt`: diff --git a/docs/howto/interop/monix.md b/docs/howto/interop/with-monix.md similarity index 97% rename from docs/howto/interop/monix.md rename to docs/howto/interop/with-monix.md index db976b18df75..a08118d3c95d 100644 --- a/docs/howto/interop/monix.md +++ b/docs/howto/interop/with-monix.md @@ -1,6 +1,6 @@ --- -id: monix -title: "Monix" +id: with-monix +title: "How to Interop with Monix?" --- Checkout `interop-monix` module for inter-operation support. diff --git a/docs/howto/interop/reactivestreams.md b/docs/howto/interop/with-reactive-streams.md similarity index 97% rename from docs/howto/interop/reactivestreams.md rename to docs/howto/interop/with-reactive-streams.md index b23e2a1c2b4e..6b0175c82bec 100644 --- a/docs/howto/interop/reactivestreams.md +++ b/docs/howto/interop/with-reactive-streams.md @@ -1,6 +1,6 @@ --- -id: reactivestreams -title: "Reactive Streams" +id: with-reactive-streams +title: "How to Interop with Reactive Streams?" --- Checkout the `interop-reactive-streams` module for inter-operation support. diff --git a/docs/howto/interop/scalaz7x.md b/docs/howto/interop/with-scalaz-7x.md similarity index 96% rename from docs/howto/interop/scalaz7x.md rename to docs/howto/interop/with-scalaz-7x.md index 2713e6c01c55..1bdd8946414a 100644 --- a/docs/howto/interop/scalaz7x.md +++ b/docs/howto/interop/with-scalaz-7x.md @@ -1,6 +1,6 @@ --- -id: scalaz7x -title: "Scalaz 7.x" +id: with-scalaz-7x +title: "How to Interop with Scalaz 7.x?" --- ## `ZIO` Instances diff --git a/docs/howto/interop/twitter.md b/docs/howto/interop/with-twitter.md similarity index 92% rename from docs/howto/interop/twitter.md rename to docs/howto/interop/with-twitter.md index bb22e4db80e1..e924830e4e1d 100644 --- a/docs/howto/interop/twitter.md +++ b/docs/howto/interop/with-twitter.md @@ -1,6 +1,6 @@ --- -id: twitter -title: "Twitter" +id: with-twitter +title: "How to Interop with Twitter?" --- `interop-twitter` module provides capability to convert Twitter `Future` into ZIO `Task`. diff --git a/website/sidebars.json b/website/sidebars.json index b480cfe96eb6..bc08db03ae86 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -113,14 +113,14 @@ "howto/use-zio-macros" ], "Interop": [ - "howto/interop/catseffect", - "howto/interop/future", - "howto/interop/java", - "howto/interop/javascript", - "howto/interop/monix", - "howto/interop/scalaz7x", - "howto/interop/reactivestreams", - "howto/interop/twitter" + "howto/interop/with-cats-effect", + "howto/interop/with-future", + "howto/interop/with-java", + "howto/interop/with-javascript", + "howto/interop/with-monix", + "howto/interop/with-scalaz-7x", + "howto/interop/with-reactive-streams", + "howto/interop/with-twitter" ], "Migrate": [ "howto/migrate/from-monix" From e45ca9f31a56be3a12ec717ac508a19b6e8de2a4 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Mon, 5 Apr 2021 22:31:55 +0430 Subject: [PATCH 28/36] remove summary page of interop. --- ...with-catseffect.md => with-cats-effect.md} | 4 ++-- docs/howto/interop/with-guava.md | 6 ++++++ docs/howto/interop/with-java.md | 2 ++ docs/howto/interop/with-monix.md | 2 +- docs/howto/interop/with-reactive-streams.md | 2 +- docs/howto/interop/with-scalaz-7x.md | 2 +- docs/howto/interop/with-twitter.md | 2 +- docs/interop/index.md | 19 ------------------- website/sidebars.json | 3 ++- 9 files changed, 16 insertions(+), 26 deletions(-) rename docs/howto/interop/{with-catseffect.md => with-cats-effect.md} (83%) create mode 100644 docs/howto/interop/with-guava.md delete mode 100644 docs/interop/index.md diff --git a/docs/howto/interop/with-catseffect.md b/docs/howto/interop/with-cats-effect.md similarity index 83% rename from docs/howto/interop/with-catseffect.md rename to docs/howto/interop/with-cats-effect.md index 63d2de727080..a59943502e6a 100644 --- a/docs/howto/interop/with-catseffect.md +++ b/docs/howto/interop/with-cats-effect.md @@ -1,9 +1,9 @@ --- -id: with-catseffect +id: with-cats-effect title: "How to Interop with Cats Effect?" --- -The `interop-cats` module provides interoperability for the Cats Effect ecosystem. +[`interop-cats`](https://github.com/zio/interop-cats) has instances for the [Cats](https://typelevel.org/cats/), [Cats MTL](https://github.com/typelevel/cats-mtl) and [Cats Effect](https://typelevel.org/cats-effect/) libraries, which allow you to use ZIO with any libraries that rely on these, like [Doobie](https://github.com/tpolecat/doobie), [Http4s](https://github.com/http4s/http4s), [FS2](https://github.com/functional-streams-for-scala/fs2) or [Circe](https://github.com/circe/circe) To use this module, add the following to your `build.sbt`: diff --git a/docs/howto/interop/with-guava.md b/docs/howto/interop/with-guava.md new file mode 100644 index 000000000000..ca1a36ef002c --- /dev/null +++ b/docs/howto/interop/with-guava.md @@ -0,0 +1,6 @@ +--- +id: with-guava +title: "How to Interop with Guava?" +--- + +[`interop-guava`](https://github.com/zio/interop-guava) module provide capibility to convert [Guava's `com.google.common.util.concurrent.ListenableFuture`](https://github.com/google/guava/wiki/ListenableFutureExplained) into ZIO `Task`. diff --git a/docs/howto/interop/with-java.md b/docs/howto/interop/with-java.md index 9261f4c7a452..c9b700a68638 100644 --- a/docs/howto/interop/with-java.md +++ b/docs/howto/interop/with-java.md @@ -5,6 +5,8 @@ title: "How to Interop with Java?" ZIO has full interoperability with foreign Java code. Let me show you how it works and then *BOOM*, tomorrow you can show off your purely functional Java at work. +ZIO has built-in conversion between ZIO data types (like `ZIO` and `Fiber`) and Java concurrent data types like [`CompletionStage`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletionStage.html), [`Future`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html) and [`CompletionHandler`](https://docs.oracle.com/javase/8/docs/api/java/nio/channels/CompletionHandler.html). + ## From Java CompletionStage and back `CompletionStage` is the interface that comes closest to emulate a functional asynchronous effects API like ZIO's, so we start with it. It's a breeze: diff --git a/docs/howto/interop/with-monix.md b/docs/howto/interop/with-monix.md index a08118d3c95d..a0261778ac29 100644 --- a/docs/howto/interop/with-monix.md +++ b/docs/howto/interop/with-monix.md @@ -3,7 +3,7 @@ id: with-monix title: "How to Interop with Monix?" --- -Checkout `interop-monix` module for inter-operation support. +Checkout [`interop-monix`](https://github.com/zio/interop-monix) module for inter-operation support. ## `Task` conversions diff --git a/docs/howto/interop/with-reactive-streams.md b/docs/howto/interop/with-reactive-streams.md index 6b0175c82bec..f1b4ec44c5d0 100644 --- a/docs/howto/interop/with-reactive-streams.md +++ b/docs/howto/interop/with-reactive-streams.md @@ -3,7 +3,7 @@ id: with-reactive-streams title: "How to Interop with Reactive Streams?" --- -Checkout the `interop-reactive-streams` module for inter-operation support. +Checkout the [`interop-reactive-streams`](https://github.com/zio/interop-reactive-streams) module for inter-operation support. ## Reactive Streams `Producer` and `Subscriber` diff --git a/docs/howto/interop/with-scalaz-7x.md b/docs/howto/interop/with-scalaz-7x.md index 1bdd8946414a..5a2824e5b89d 100644 --- a/docs/howto/interop/with-scalaz-7x.md +++ b/docs/howto/interop/with-scalaz-7x.md @@ -5,7 +5,7 @@ title: "How to Interop with Scalaz 7.x?" ## `ZIO` Instances -If you are a happy Scalaz 7.2 user `interop-scala7x` module offers `ZIO` instances for several typeclasses, check out [the source code](https://github.com/scalaz/scalaz-zio/interop-scalaz7x/jvm/src/main/scala/scalaz/zio/interop/scalaz72.scala) for more details. +If you are a happy Scalaz 7.2 user [`interop-scala7x`](https://github.com/zio/interop-scalaz) module offers `ZIO` instances for several typeclasses. ### Example diff --git a/docs/howto/interop/with-twitter.md b/docs/howto/interop/with-twitter.md index e924830e4e1d..706bf0897323 100644 --- a/docs/howto/interop/with-twitter.md +++ b/docs/howto/interop/with-twitter.md @@ -3,7 +3,7 @@ id: with-twitter title: "How to Interop with Twitter?" --- -`interop-twitter` module provides capability to convert Twitter `Future` into ZIO `Task`. +[`interop-twitter`](https://github.com/zio/interop-twitter) module provides capability to convert [Twitter `Future`](https://twitter.github.io/util/docs/com/twitter/util/Future.html) into ZIO `Task`. ### Example diff --git a/docs/interop/index.md b/docs/interop/index.md deleted file mode 100644 index 82b7750fb677..000000000000 --- a/docs/interop/index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -id: interop_index -title: "Summary" ---- - -ZIO provides the ability to interoperate with other parts of the broader ecosystem, including: - - - **Future** — ZIO has built-in conversion between ZIO data types (like `ZIO` and `Fiber`) and Scala concurrent data types like `Future`. - - **Java** — ZIO has built-in conversion between ZIO data types (like `ZIO` and `Fiber`) and Java concurrent data types like [`CompletionStage`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletionStage.html), [`Future`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html) and [`CompletionHandler`](https://docs.oracle.com/javase/8/docs/api/java/nio/channels/CompletionHandler.html). - - **JavaScript** — ZIO has first-class support for Scala.js. - - **Scalaz 8** — Scalaz 8 depends on ZIO, and contains instances for all ZIO data types inside the library. No additional modules are needed. -- [`interop-cats`](https://github.com/zio/interop-cats) has instances for the [Cats](https://typelevel.org/cats/), [Cats MTL](https://github.com/typelevel/cats-mtl) and [Cats Effect](https://typelevel.org/cats-effect/) libraries, which allow you to use ZIO with any libraries that rely on these, like [Doobie](https://github.com/tpolecat/doobie), [Http4s](https://github.com/http4s/http4s), [FS2](https://github.com/functional-streams-for-scala/fs2) or [Circe](https://github.com/circe/circe) -- [`interop-reactive-streams`](https://github.com/zio/interop-reactive-streams) for [Reactive Streams](http://www.reactive-streams.org/), has conversion from ZIO Streams and Sinks to Reactive Streams Producers and Consumers -- [`interop-scalaz`](https://github.com/zio/interop-scalaz) for [ScalaZ 7](https://scalaz.github.io/7/), has instances of `Monad` and other type classes for the ZIO data types -- [`interop-twitter`](https://github.com/zio/interop-twitter) for [Twitter's `com.twitter.util.Future`](https://twitter.github.io/util/docs/com/twitter/util/Future.html) -- [`interop-monix`](https://github.com/zio/interop-monix) for [Monix's `monix.eval.Task` and `monix.eval.Coeval`](https://monix.io/docs/3x/) -- [`interop-guava`](https://github.com/zio/interop-guava) for [Guava's `com.google.common.util.concurrent.ListenableFuture`](https://github.com/google/guava/wiki/ListenableFutureExplained) - -Explore the sections above to learn how easy it is to integrate ZIO with whatever libraries or platforms you are already using. diff --git a/website/sidebars.json b/website/sidebars.json index bc08db03ae86..83ccd7bd7d56 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -120,7 +120,8 @@ "howto/interop/with-monix", "howto/interop/with-scalaz-7x", "howto/interop/with-reactive-streams", - "howto/interop/with-twitter" + "howto/interop/with-twitter", + "howto/interop/with-guava" ], "Migrate": [ "howto/migrate/from-monix" From c0a600523b7737497ab33158b6b335b10f35d9b1 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Tue, 6 Apr 2021 10:49:34 +0430 Subject: [PATCH 29/36] add a quick note on what do we mean by type alias. --- docs/datatypes/core/rio.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/datatypes/core/rio.md b/docs/datatypes/core/rio.md index e760af069925..0cef075533f9 100644 --- a/docs/datatypes/core/rio.md +++ b/docs/datatypes/core/rio.md @@ -4,3 +4,14 @@ title: "RIO" --- `RIO[R, A]` is a type alias for `ZIO[R, Throwable, A]`, which represents an effect that requires an `R`, and may fail with a `Throwable` value, or succeed with an `A`. + +Let's see how `RIO` is defined: +```scala mdoc:invisible +import zio.ZIO +``` + +```scala mdoc:silent +type RIO[-R, +A] = ZIO[R, Throwable, A] +``` + +So the `RIO` just equal to `ZIO` which its error channel is `Throwable`. \ No newline at end of file From e874b2d59f447f80bb65ae3322327977d90a0d2c Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Tue, 6 Apr 2021 10:55:25 +0430 Subject: [PATCH 30/36] add a note on how the IO type alias is defined. --- docs/datatypes/core/io.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/datatypes/core/io.md b/docs/datatypes/core/io.md index c9ecdad042b5..0860a34df753 100644 --- a/docs/datatypes/core/io.md +++ b/docs/datatypes/core/io.md @@ -5,6 +5,18 @@ title: "IO" `IO[E, A]` is a type alias for `ZIO[Any, E, A]`, which represents an effect that has no requirements, and may fail with an `E`, or succeed with an `A`. +Let's see how the `IO` type alias is defined: + +```scala mdoc:invisible +import zio.ZIO +``` + +```scala mdoc:silent +type IO[+E, +A] = ZIO[Any, E, A] +``` + +So the `IO` just equal to `ZIO` which doesn't need any requirement. + ## Unproductive IO `ZIO` values of type `IO[E, Nothing]` (where the value type is `Nothing`) are considered _unproductive_, From 55ef3a550b55d0d0c950e03e57873340bdb12772 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Tue, 6 Apr 2021 11:04:33 +0430 Subject: [PATCH 31/36] add a note on how the UIO type alias is defined. --- docs/datatypes/core/uio.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/datatypes/core/uio.md b/docs/datatypes/core/uio.md index df260c037fa3..dea3c1e73e51 100644 --- a/docs/datatypes/core/uio.md +++ b/docs/datatypes/core/uio.md @@ -5,6 +5,18 @@ title: "UIO" `UIO[A]` is a type alias for `ZIO[Any, Nothing, A]`, which represents an **Unexceptional** effect that doesn't require any specific environment, and cannot fail, but can succeed with an `A`. +Let's see how the `UIO` type alias is defined: + +```scala mdoc:invisible +import zio.ZIO +``` + +```scala mdoc:silent +type UIO[+A] = ZIO[Any, Nothing, A] +``` + +So the `UIO` just equal to `ZIO` which doesn't need any requirement and cannot fail because in the Scala the `Nothing` type has no inhabitant, we can't create an instance of type `Nothing`. + `ZIO` values of type `UIO[A]` (where the error type is `Nothing`) are considered _infallible_, because the `Nothing` type is _uninhabitable_, i.e. there can be no actual values of type `Nothing`. Values of this type may produce an `A`, but will never fail with an `E`. From f7d014ce8b8d2384ecede06aa2d5f5836f1b4b88 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Tue, 6 Apr 2021 11:25:38 +0430 Subject: [PATCH 32/36] add a note on how the URIO type alias is defined. --- docs/datatypes/core/urio.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/datatypes/core/urio.md b/docs/datatypes/core/urio.md index d04a6a9b2131..057d8a7a9630 100644 --- a/docs/datatypes/core/urio.md +++ b/docs/datatypes/core/urio.md @@ -5,8 +5,21 @@ title: "URIO" `URIO[R, A]` is a type alias for `ZIO[R, Nothing, A]`, which represents an effect that requires an `R`, and cannot fail, but can succeed with an `A`. -In following example, the type of `putStrLn` is `URIO[Console, Unit]` which means, it requires `Console` service as an environment, and it succeeds with `Unit` value: +Let's see how the `URIO` type alias is defined: + ```scala mdoc:invisible +import zio.ZIO +``` + +```scala mdoc:silent +type URIO[-R, +A] = ZIO[R, Nothing, A] +``` + +So the `URIO` just equal to `ZIO` which requires `R` and cannot fail because in the Scala the `Nothing` type has no inhabitant, we can't create an instance of type `Nothing`. It succeeds with `A`. + +In following example, the type of `putStrLn` is `URIO[Console, Unit]` which means, it requires `Console` service as an environment, and it succeeds with `Unit` value: + +```scala mdoc:invisible:reset import zio._ import zio.console._ ``` From 81e56dd816ac4efcfa6b4d256a45ba47e91ee5ad Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Tue, 6 Apr 2021 11:31:57 +0430 Subject: [PATCH 33/36] add a note on how the Task type alias is defined. --- docs/datatypes/core/task.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/datatypes/core/task.md b/docs/datatypes/core/task.md index e0f7cfa8ebff..e614d6896b2d 100644 --- a/docs/datatypes/core/task.md +++ b/docs/datatypes/core/task.md @@ -5,6 +5,18 @@ title: "Task" `Task[A]` is a type alias for `ZIO[Any, Throwable, A]`, which represents an effect that has no requirements, and may fail with a `Throwable` value, or succeed with an `A`. +Let's see how the `Task` type alias is defined: + +```scala mdoc:invisible +import zio.ZIO +``` + +```scala mdoc:silent +type Task[+A] = ZIO[Any, Throwable, A] +``` + +So the `Task` just equal to `ZIO` which doesn't require any dependency. Its error channel is `Throwable`, so it may fail with `Throwable` and may succeed with an `A` value. + Some time, we know that our effect may fail, but we don't care the type of that exception, this is where we can use `Task`. The type signature of this type-alias is similar to the `Future[T]` and Cats `IO`. If we want to be less precise and want to eliminate the need to think about requirements and error types, we can use `Task`. This type-alias is a good start point for anyone who wants to refactor the current code base which is written in Cats `IO` or Monix `Task`. From cef5b35377a197cbeaeb5623c10d91de10737038 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Tue, 6 Apr 2021 11:53:59 +0430 Subject: [PATCH 34/36] add a note on type aliases. --- docs/datatypes/core/io.md | 4 ++++ docs/datatypes/core/rio.md | 6 +++++- docs/datatypes/core/task.md | 4 ++++ docs/datatypes/core/uio.md | 4 ++++ docs/datatypes/core/urio.md | 4 ++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/datatypes/core/io.md b/docs/datatypes/core/io.md index 0860a34df753..4df931aba037 100644 --- a/docs/datatypes/core/io.md +++ b/docs/datatypes/core/io.md @@ -17,6 +17,10 @@ type IO[+E, +A] = ZIO[Any, E, A] So the `IO` just equal to `ZIO` which doesn't need any requirement. +> **_Note:_** +> +> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. + ## Unproductive IO `ZIO` values of type `IO[E, Nothing]` (where the value type is `Nothing`) are considered _unproductive_, diff --git a/docs/datatypes/core/rio.md b/docs/datatypes/core/rio.md index 0cef075533f9..e96c04b8b396 100644 --- a/docs/datatypes/core/rio.md +++ b/docs/datatypes/core/rio.md @@ -14,4 +14,8 @@ import zio.ZIO type RIO[-R, +A] = ZIO[R, Throwable, A] ``` -So the `RIO` just equal to `ZIO` which its error channel is `Throwable`. \ No newline at end of file +So the `RIO` just equal to `ZIO` which its error channel is `Throwable`. + +> **_Note:_** +> +> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. diff --git a/docs/datatypes/core/task.md b/docs/datatypes/core/task.md index e614d6896b2d..65036b237996 100644 --- a/docs/datatypes/core/task.md +++ b/docs/datatypes/core/task.md @@ -17,6 +17,10 @@ type Task[+A] = ZIO[Any, Throwable, A] So the `Task` just equal to `ZIO` which doesn't require any dependency. Its error channel is `Throwable`, so it may fail with `Throwable` and may succeed with an `A` value. +> **_Note:_** +> +> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. + Some time, we know that our effect may fail, but we don't care the type of that exception, this is where we can use `Task`. The type signature of this type-alias is similar to the `Future[T]` and Cats `IO`. If we want to be less precise and want to eliminate the need to think about requirements and error types, we can use `Task`. This type-alias is a good start point for anyone who wants to refactor the current code base which is written in Cats `IO` or Monix `Task`. diff --git a/docs/datatypes/core/uio.md b/docs/datatypes/core/uio.md index dea3c1e73e51..49e6240111ef 100644 --- a/docs/datatypes/core/uio.md +++ b/docs/datatypes/core/uio.md @@ -17,6 +17,10 @@ type UIO[+A] = ZIO[Any, Nothing, A] So the `UIO` just equal to `ZIO` which doesn't need any requirement and cannot fail because in the Scala the `Nothing` type has no inhabitant, we can't create an instance of type `Nothing`. +> **_Note:_** +> +> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. + `ZIO` values of type `UIO[A]` (where the error type is `Nothing`) are considered _infallible_, because the `Nothing` type is _uninhabitable_, i.e. there can be no actual values of type `Nothing`. Values of this type may produce an `A`, but will never fail with an `E`. diff --git a/docs/datatypes/core/urio.md b/docs/datatypes/core/urio.md index 057d8a7a9630..a49305a4f8c0 100644 --- a/docs/datatypes/core/urio.md +++ b/docs/datatypes/core/urio.md @@ -17,6 +17,10 @@ type URIO[-R, +A] = ZIO[R, Nothing, A] So the `URIO` just equal to `ZIO` which requires `R` and cannot fail because in the Scala the `Nothing` type has no inhabitant, we can't create an instance of type `Nothing`. It succeeds with `A`. +> **_Note:_** +> +> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. + In following example, the type of `putStrLn` is `URIO[Console, Unit]` which means, it requires `Console` service as an environment, and it succeeds with `Unit` value: ```scala mdoc:invisible:reset From 1996267492def21a8e2dd8afbc81d142b00b7498 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Tue, 6 Apr 2021 13:59:45 +0430 Subject: [PATCH 35/36] add a note on the principle of the least power for each type alias. --- docs/datatypes/core/io.md | 19 ++++++++++++------- docs/datatypes/core/rio.md | 13 +++++++++++-- docs/datatypes/core/task.md | 10 +++++++++- docs/datatypes/core/uio.md | 16 ++++++++++++---- docs/datatypes/core/urio.md | 16 ++++++++++++---- 5 files changed, 56 insertions(+), 18 deletions(-) diff --git a/docs/datatypes/core/io.md b/docs/datatypes/core/io.md index 4df931aba037..1ffe801479b0 100644 --- a/docs/datatypes/core/io.md +++ b/docs/datatypes/core/io.md @@ -5,6 +5,10 @@ title: "IO" `IO[E, A]` is a type alias for `ZIO[Any, E, A]`, which represents an effect that has no requirements, and may fail with an `E`, or succeed with an `A`. +> **Note:** +> +> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. + Let's see how the `IO` type alias is defined: ```scala mdoc:invisible @@ -17,11 +21,12 @@ type IO[+E, +A] = ZIO[Any, E, A] So the `IO` just equal to `ZIO` which doesn't need any requirement. -> **_Note:_** -> -> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. +`ZIO` values of type `IO[E, Nothing]` (where the value type is `Nothing`) are considered _unproductive_, because the `Nothing` type is _uninhabitable_, i.e. there can be no actual values of type `Nothing`. Values of this type may fail with an `E`, but will never produce a value. -## Unproductive IO - -`ZIO` values of type `IO[E, Nothing]` (where the value type is `Nothing`) are considered _unproductive_, -because the `Nothing` type is _uninhabitable_, i.e. there can be no actual values of type `Nothing`. Values of this type may fail with an `E`, but will never produce a value. +> **Note:** _Principle of The Least Power_ +> +> The `ZIO` data type is the most powerful effect in the ZIO library. It helps us to model various types of workflows. On other hand, the type aliases are a way of subtyping and specializing the `ZIO` type, specific for a less powerful workflow. +> +> Lot of the time, we don't need such a piece of powerful machinery. So as a rule of thumb, whenever we require a less powerful effect, it's better to use the proper specialized type alias. +> +> So there is no need to convert type aliases to the `ZIO` data type, whenever the `ZIO` data type is required, we can use the most precise type alias to fit our workflow requirement. diff --git a/docs/datatypes/core/rio.md b/docs/datatypes/core/rio.md index e96c04b8b396..f95f03a3137a 100644 --- a/docs/datatypes/core/rio.md +++ b/docs/datatypes/core/rio.md @@ -5,6 +5,10 @@ title: "RIO" `RIO[R, A]` is a type alias for `ZIO[R, Throwable, A]`, which represents an effect that requires an `R`, and may fail with a `Throwable` value, or succeed with an `A`. +> **_Note:_** +> +> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. + Let's see how `RIO` is defined: ```scala mdoc:invisible import zio.ZIO @@ -16,6 +20,11 @@ type RIO[-R, +A] = ZIO[R, Throwable, A] So the `RIO` just equal to `ZIO` which its error channel is `Throwable`. -> **_Note:_** + +> **Note:** _Principle of The Least Power_ > -> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. +> The `ZIO` data type is the most powerful effect in the ZIO library. It helps us to model various types of workflows. On other hand, the type aliases are a way of subtyping and specializing the `ZIO` type, specific for a less powerful workflow. +> +> Lot of the time, we don't need such a piece of powerful machinery. So as a rule of thumb, whenever we require a less powerful effect, it's better to use the proper specialized type alias. +> +> So there is no need to convert type aliases to the `ZIO` data type, whenever the `ZIO` data type is required, we can use the most precise type alias to fit our workflow requirement. diff --git a/docs/datatypes/core/task.md b/docs/datatypes/core/task.md index 65036b237996..8aa74e3b6ef3 100644 --- a/docs/datatypes/core/task.md +++ b/docs/datatypes/core/task.md @@ -17,10 +17,18 @@ type Task[+A] = ZIO[Any, Throwable, A] So the `Task` just equal to `ZIO` which doesn't require any dependency. Its error channel is `Throwable`, so it may fail with `Throwable` and may succeed with an `A` value. -> **_Note:_** +> **Note:** > > In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. Some time, we know that our effect may fail, but we don't care the type of that exception, this is where we can use `Task`. The type signature of this type-alias is similar to the `Future[T]` and Cats `IO`. If we want to be less precise and want to eliminate the need to think about requirements and error types, we can use `Task`. This type-alias is a good start point for anyone who wants to refactor the current code base which is written in Cats `IO` or Monix `Task`. + +> **Note:** _Principle of The Least Power_ +> +> The `ZIO` data type is the most powerful effect in the ZIO library. It helps us to model various types of workflows. On other hand, the type aliases are a way of subtyping and specializing the `ZIO` type, specific for a less powerful workflow. +> +> Lot of the time, we don't need such a piece of powerful machinery. So as a rule of thumb, whenever we require a less powerful effect, it's better to use the proper specialized type alias. +> +> So there is no need to convert type aliases to the `ZIO` data type, whenever the `ZIO` data type is required, we can use the most precise type alias to fit our workflow requirement. diff --git a/docs/datatypes/core/uio.md b/docs/datatypes/core/uio.md index 49e6240111ef..b9f374d25473 100644 --- a/docs/datatypes/core/uio.md +++ b/docs/datatypes/core/uio.md @@ -5,6 +5,10 @@ title: "UIO" `UIO[A]` is a type alias for `ZIO[Any, Nothing, A]`, which represents an **Unexceptional** effect that doesn't require any specific environment, and cannot fail, but can succeed with an `A`. +> **_Note:_** +> +> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. + Let's see how the `UIO` type alias is defined: ```scala mdoc:invisible @@ -17,10 +21,6 @@ type UIO[+A] = ZIO[Any, Nothing, A] So the `UIO` just equal to `ZIO` which doesn't need any requirement and cannot fail because in the Scala the `Nothing` type has no inhabitant, we can't create an instance of type `Nothing`. -> **_Note:_** -> -> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. - `ZIO` values of type `UIO[A]` (where the error type is `Nothing`) are considered _infallible_, because the `Nothing` type is _uninhabitable_, i.e. there can be no actual values of type `Nothing`. Values of this type may produce an `A`, but will never fail with an `E`. @@ -42,3 +42,11 @@ def fib(n: Int): UIO[Int] = } yield v1 + v2 } ``` + +> **Note:** _Principle of The Least Power_ +> +> The `ZIO` data type is the most powerful effect in the ZIO library. It helps us to model various types of workflows. On other hand, the type aliases are a way of subtyping and specializing the `ZIO` type, specific for a less powerful workflow. +> +> Lot of the time, we don't need such a piece of powerful machinery. So as a rule of thumb, whenever we require a less powerful effect, it's better to use the proper specialized type alias. +> +> So there is no need to convert type aliases to the `ZIO` data type, whenever the `ZIO` data type is required, we can use the most precise type alias to fit our workflow requirement. diff --git a/docs/datatypes/core/urio.md b/docs/datatypes/core/urio.md index a49305a4f8c0..03c4536fccdc 100644 --- a/docs/datatypes/core/urio.md +++ b/docs/datatypes/core/urio.md @@ -5,6 +5,10 @@ title: "URIO" `URIO[R, A]` is a type alias for `ZIO[R, Nothing, A]`, which represents an effect that requires an `R`, and cannot fail, but can succeed with an `A`. +> **_Note:_** +> +> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. + Let's see how the `URIO` type alias is defined: ```scala mdoc:invisible @@ -17,10 +21,6 @@ type URIO[-R, +A] = ZIO[R, Nothing, A] So the `URIO` just equal to `ZIO` which requires `R` and cannot fail because in the Scala the `Nothing` type has no inhabitant, we can't create an instance of type `Nothing`. It succeeds with `A`. -> **_Note:_** -> -> In Scala, the _type alias_ is a way to give a name to another type, to avoid having to repeat the original type again and again. It doesn't affect the type-checking process. It just helps us to have an expressive API design. - In following example, the type of `putStrLn` is `URIO[Console, Unit]` which means, it requires `Console` service as an environment, and it succeeds with `Unit` value: ```scala mdoc:invisible:reset @@ -32,3 +32,11 @@ import zio.console._ def putStrLn(line: => String): URIO[Console, Unit] = ZIO.accessM(_.get putStrLn line) ``` + +> **Note:** _Principle of The Least Power_ +> +> The `ZIO` data type is the most powerful effect in the ZIO library. It helps us to model various types of workflows. On other hand, the type aliases are a way of subtyping and specializing the `ZIO` type, specific for a less powerful workflow. +> +> Lot of the time, we don't need such a piece of powerful machinery. So as a rule of thumb, whenever we require a less powerful effect, it's better to use the proper specialized type alias. +> +> So there is no need to convert type aliases to the `ZIO` data type, whenever the `ZIO` data type is required, we can use the most precise type alias to fit our workflow requirement. From 2453c27e07574ab216744a26045c92dd92d20201 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Tue, 6 Apr 2021 15:49:33 +0430 Subject: [PATCH 36/36] add a video from Justin. --- docs/resources/learning/videos.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/resources/learning/videos.md b/docs/resources/learning/videos.md index c56c253f7963..be90e3a31584 100644 --- a/docs/resources/learning/videos.md +++ b/docs/resources/learning/videos.md @@ -48,5 +48,8 @@ title: "Videos" ## ZIO Actors - [Acting Lessons for Scala Engineers with Akka and ZIO](https://www.youtube.com/watch?v=AQXBlbkf9wc) by [Salar Rahmanian](https://wwww.softinio.com) (November 2020) +## Use Cases +- [Search Hacker News with ZIO with Scala, ZIO, Sttp and magic](https://www.youtube.com/watch?v=3P2Gi--dG9A&list=PL-G8WBFTPSVpCcFq6O7czfx9m9T21Cz24&index=11) — A practical look at building a ZIO program. + [Source Code](https://github.com/justinhj/magic-rate-limiter) by [Justin Heyes-Jones](https://twitter.com/justinhj) (April 2021) + ## Others - [Redis Streams with ZIO](https://youtu.be/jJnco6sMZQY) by [Leszek Gruchała](https://twitter.com/leszekgruchala) (October 2020)