Skip to content

Commit fce1b33

Browse files
authored
Update README.md
1 parent 9d38887 commit fce1b33

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# An error typed Future
1+
# An error typed Future[+E, +A]
22
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)
33

4-
A thin wrapper on the Future monad for the purpose of giving it an error type.
5-
Designed to be an alternative for the `scala.concurrent.Future` with minimal migration needed. Entirely built on top
4+
A thin wrapper on the Future monad for the purpose of giving it a type parameter for the error channel, giving you
5+
the power to see _how_ a Future can fail just as clearly as how it can succeed.
6+
Designed to be an alternative for the `scala.concurrent.Future` with minimal migration needed, entirely built on top
67
of the Future, it has
78
the same performance and easily integrates into existing Future
89
based libraries.
@@ -20,19 +21,19 @@ still want typed errors feel free to use this library, or copy the code to your
2021
Setup via `build.sbt`:
2122

2223
```sbt
23-
libraryDependencies += "io.github.ragazoor" %% "task" % "0.1.15"
24+
libraryDependencies += "io.github.ragazoor" %% "task" % "0.1.16"
2425
```
2526

2627
# Getting Started
2728

28-
In this library the main monad is called a `Task`, which has the type signature `Task[+E, +A]`.
29+
In this library the monad is called a `Task`, which has the type signature `Task[+E, +A]`.
2930
This `Task` is just a thin wrapper on top of the Future we know from Scala, which we have defined here as the
30-
type alias `type Future[+A] = Task[Throwable, A]`. This is so that there is less migration needed if you were to adopt this library.
31+
type alias `type Future[+A] = Task[Throwable, A]`. This is to keep backward compatability if you were to adopt this library.
3132

3233
## Examples
3334

3435
In `io.github.ragazoor.implicits._` there is an implicit class that
35-
allows you to convert from an `StdFuture` to a `Task` using `.toTask`.
36+
allows you to convert from an `scala.concurrent.Future` to a `Task` using `.toTask`.
3637
```scala
3738
import common.User
3839
import io.github.ragazoor.Future
@@ -47,7 +48,7 @@ class UserExample(userRepo: UserRepository) {
4748
def getUser(id: Int): Future[User] = // Future[User] is an alias for Task[Throwable, User]
4849
userRepo
4950
.getUser(id) // This returns a scala.concurrent.Future
50-
.toTask // Converts to Task
51+
.toTask // Converts to Task[Throwable, User]
5152
}
5253
```
5354

@@ -73,20 +74,19 @@ trait UserProcess {
7374
class UserServiceFutureExample(userProcess: UserProcess)(implicit ec: ExecutionContext) {
7475

7576
def processUser(userTask: Task[User]): Task[Throwable, User] =
76-
userProcess.process(userTask) // Here Task -> Future conversion is implicit
77+
userProcess.process(userTask) // Using scala.concurrent.Future as input and output, implicit conversion
7778
.toTask
7879

7980
// Does the same thing without implicits, but more migration needed
8081
def processUser2(userTask: Task[User]): Task[Throwable, User] =
81-
userProcess.process(userTask.toFuture) // Here Task -> Future conversion is explicit
82+
userProcess.process(userTask.toFuture) // Using scala.concurrent.Future as input and output, explicit conversion
8283
.toTask
8384
}
8485

8586
```
8687

8788
This is the basics for using the `Task` type in
88-
your code. The Task has the same API
89-
as the Future, and thanks to the type alias
89+
your code. The Task has the same API as the Future, and thanks to the type alias
9090
`type Future[+A] = Task[Throwable, A]` we don't need to rename a lot of unnecessary renaming.
9191

9292
### Error handling

0 commit comments

Comments
 (0)