Skip to content

Add paragraph in fx explaining compatibility with existing datatypes #1302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions modules/docs/arrow-docs/docs/docs/effects/fx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,27 @@ fun greet(): IO<Unit> =

Arrow enforces usage to be explicit about effects application.

#### Applying existing datatypes

Composition using regular datatypes such as `IO` is still possible within `fx` blocks the same way as `effect` blocks. In addition to `!` you can also use the extension function `bind()` to execute them.

```kotlin:ank:playground
import arrow.effects.IO
import arrow.effects.extensions.io.fx.fx
//sampleStart
fun sayInIO(s: String): IO<Unit> =
IO { println(s) }

fun greet(): IO<Unit> =
fx {
sayInIO("Hello World").bind()
}
//sampleEnd
fun main() {
println(greet()) //greet is a pure IO program
}
```

## Executing effectful programs

The `greet` program is ready to run as soon as the user is ready to commit to an execution strategy that is either `blocking` or `non-blocking`.
Expand Down