Skip to content

Commit

Permalink
Ap docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianRaFo committed Mar 21, 2018
1 parent eac1ddb commit 6e6ac9a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion modules/docs/arrow-docs/docs/docs/datatypes/kleisli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ we want to do a safe conversion like this:

```kotlin:ank:silent
import arrow.core.*
import arrow.data.*
import arrow.data.Kleisli
val optionIntKleisli = Kleisli { str: String ->
if (str.toCharArray().all { it.isDigit() }) Some(str.toInt()) else None
Expand Down Expand Up @@ -43,6 +43,21 @@ This function allows doing a conversion inside the Kleisli to the original input
optionIntKleisli.local { optStr :Option<String> -> optStr.getOrElse { "0" } }.run(None)
```

#### Ap
The `ap` function transform the `Kleisli` into another `Kleisli` with a function as a output value.

```kotlin:ank
import arrow.data.fix
val intToDouble = {number:Int -> number.toDouble()}
val optionIntDoubleKleisli = Kleisli { str: String ->
if (str.toCharArray().all { it.isDigit() }) Some(intToDouble) else None
}
optionIntKleisli.ap(optionIntDoubleKleisli,Option.applicative()).fix().run("1")
```

#### Map
The `map` function transform the `Kleisli` output value.

Expand Down

0 comments on commit 6e6ac9a

Please sign in to comment.