Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions modules/docs/arrow-docs/docs/docs/effects/fx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ Applying and composing suspended side effects is allowed in the presence of othe

In the example below, `sayHello` and `sayGoodBye` are valid inside `greet` because they are all suspended functions.

```kotlin:ank:playground
//sampleStart
```kotlin
suspend fun sayGoodBye(): Unit =
println("Good bye World!")

Expand All @@ -86,7 +85,6 @@ suspend fun greet(): Unit {
sayHello() // this is ok because
sayGoodBye() // `greet` is also `suspend`
}
//sampleEnd
```

#### `fx` composition
Expand Down
11 changes: 6 additions & 5 deletions modules/docs/arrow-docs/docs/docs/effects/fx/async/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ suspend fun threadName(): String =
Thread.currentThread().name

data class ThreadInfo(
val threadA : String,
val threadA: String,
val threadB: String
)

Expand Down Expand Up @@ -187,12 +187,13 @@ import arrow.effects.IO
import arrow.unsafe
import arrow.effects.extensions.io.unsafeRun.runBlocking
import arrow.effects.extensions.io.fx.fxCancellable

fun main() { // The edge of our world
//sampleStart
val (_, disposable) = fxCancellable {
!effect { println("BOOM!") }
}
val (_, disposable) = fxCancellable {
!effect { println("BOOM!") }
}
//sampleEnd
fun main() { // The edge of our world
println(disposable)
}
```
Expand Down
22 changes: 12 additions & 10 deletions modules/docs/arrow-docs/docs/docs/effects/fx/polymorphism/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ fun <F> UnsafeRun<F>.main(fx: Fx<F>): Int =
unsafe { runBlocking { fx.program() } }

/* Run program in the IO monad */
fun main() =
IO.unsafeRun().main(IO.fx())
fun main(args: Array<String>) {
IO.unsafeRun().main(IO.fx())
}
//sampleEnd
```

Expand Down Expand Up @@ -187,23 +188,24 @@ Arrow identifies non-blocking binding in these non-commutative monads as unsafe
For consistency, if you want to shoot yourself in the foot, performing free environmental effect application for these non-commutative types requires the user to give explicit permission to activate the unsafe `fx` block.

```kotlin:ank:playground
import arrow.unsafe
import arrow.core.toT
import arrow.data.extensions.list.fx.fx
import arrow.data.k
import arrow.unsafe

//sampleStart
val result1 = unsafe {
val result1 = unsafe {
fx {
val (a) = listOf(1, 2)
val (b) = listOf(true, false)
val a = !listOf(1, 2).k()
val b = !listOf(true, false).k()
a toT b
}
}

val result2 = unsafe {
fx {
val (b) = listOf(true, false)
listOf(1, 2) toT b
val b = !listOf(true, false).k()
!listOf(1, 2).k() toT b
}
}
//sampleEnd
Expand All @@ -226,14 +228,14 @@ import arrow.effects.extensions.io.fx.fx
import arrow.core.toT

//sampleStart
val result1 =
val result1 =
fx {
val a = !effect { 1 }
val b = !effect { 2 }
a toT b
}

val result2 =
val result2 =
fx {
val b = !effect { 2 }
!effect { 1 } toT b
Expand Down