Skip to content

Commit 00965bb

Browse files
Update README.md
1 parent 54c096f commit 00965bb

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

docs/index.md.bak

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
id: index
3+
title: "Introduction to ZIO Interop Scalaz"
4+
sidebar_label: "ZIO Interop Scalaz"
5+
---
6+
7+
This library provides instances for several Scalaz typeclasses.
8+
9+
@PROJECT_BADGES@
10+
11+
## Installation
12+
13+
In order to use this library, we need to add the following line in our `build.sbt` file:
14+
15+
```scala
16+
libraryDependencies += "dev.zio" %% "zio-interop-scalaz" % "@VERSION@"
17+
```
18+
19+
## Example 1
20+
21+
```scala
22+
import scalaz._, Scalaz._
23+
import zio.interop.scalaz._
24+
25+
type Database = IList[User]
26+
27+
def findUser(id: UserId): ZIO[Database, UserError, User] = ...
28+
def findUsers(ids: IList[UserId]): ZIO[Database, UserError, IList[User]] = ids.traverse(findUser(_))
29+
```
30+
31+
## `ZIO` parallel `Applicative` instance
32+
33+
Due to `Applicative` and `Monad` coherence law `ZIO`'s `Applicative` instance has to be implemented in terms of `bind` hence when composing multiple effects using `Applicative` they will be sequenced. To cope with that limitation `ZIO` tagged with `Parallel` has an `Applicative` instance which is not `Monad` and operates in parallel.
34+
35+
## Example 2
36+
37+
```scala
38+
import scalaz._, Scalaz._
39+
import zio.interop.scalaz._
40+
41+
case class Dashboard(details: UserDetails, history: TransactionHistory)
42+
43+
def getDetails(id: UserId): ZIO[Database, UserError, UserDetails] = ...
44+
def getHistory(id: UserId): ZIO[Database, UserError, TransactionHistory] = ...
45+
46+
def buildDashboard(id: UserId): ZIO[Database, UserError, Dashboard] =
47+
Tag.unwrap(^(par(getDetails(id)), par(getHistory(id)))(Dashboard.apply))
48+
49+
def par[R, E, A](io: ZIO[R, E, A]): ParIO[R, E, A] = Tag(io)
50+
```

0 commit comments

Comments
 (0)