This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.fortyseven.fptraining.slides | |
import arrow.Kind | |
import arrow.core.Either | |
import arrow.core.None | |
import arrow.core.Option | |
import arrow.core.Some | |
import arrow.core.Tuple2 | |
import arrow.core.getOrElse | |
import arrow.fx.IO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import reactor.core.publisher.Mono | |
import java.util.concurrent.Executor | |
fun noTrampolining(): Mono<Int> { | |
var initial = Mono.just(0) | |
(0..5000).forEach { i -> | |
initial = initial.map { i } | |
} | |
return initial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun add1(myState: Ref<ForIO, List<String>>): IO<Unit> = | |
IO.sleep(5.seconds).followedBy(myState.update { it + listOf("#1") }) | |
fun add2(myState: Ref<ForIO, List<String>>): IO<Unit> = | |
IO.sleep(3.seconds).followedBy(myState.update { it + listOf("#2") }) | |
fun read(myState: Ref<ForIO, List<String>>): IO<Unit> = | |
myState.get().effectMap { state -> println("$state") } | |
suspend fun main(): Unit = IO.fx { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.nomisRev.androidarchitecture.espresso.rx; | |
import android.support.test.espresso.idling.CountingIdlingResource; | |
import java.util.concurrent.TimeUnit; | |
import io.reactivex.Scheduler; | |
import io.reactivex.annotations.NonNull; | |
import io.reactivex.disposables.Disposable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arrow.Kind | |
import arrow.effects.typeclasses.MonadDefer | |
import arrow.typeclasses.binding | |
import kotlinx.coroutines.experimental.* | |
class Counter<F>(private val id: Int, | |
private val ref: Ref<F, Int>, | |
private val MD: MonadDefer<F>) { | |
private fun log(value: String): Kind<F, Unit> = MD { println(value) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.softwaremill.freemonads | |
import cats.free.Free | |
import cats.~> | |
import cats._, cats.std.all._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.Future | |
sealed trait External[A] | |
case class Tickets(count: Int) extends AnyVal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arrow.InstanceParametrizedType | |
import arrow.instance | |
import retrofit2.Converter | |
import okhttp3.ResponseBody | |
import helios.core.Json | |
import retrofit2.Retrofit | |
import java.lang.reflect.Type | |
import okhttp3.RequestBody | |
import helios.typeclasses.Encoder | |
import okhttp3.MediaType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@lenses data class Street(val number: Int, val name: String) | |
@lenses data class Address(val city: String, val street: Street) | |
@lenses data class Company(val name: String, val address: Address) | |
@lenses data class Employee(val name: String, val company: Company?) | |
@lenses data class Employees(val employees: ListKW<Employee>) | |
employees.setter().employees.each().company.nullable.address.street.name | |
.modify(String::toUpperCase) //modifies all employees companies address street name. | |
employees.setter().employees.get(0).company.nullable.address.street.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arrow.core.Option | |
import arrow.core.identity | |
import arrow.data.ListKW | |
import arrow.data.ListKWHK | |
import arrow.data.ListKWKind | |
import arrow.data.ev | |
import arrow.data.k | |
import arrow.lenses | |
interface BoundSetter<S, A> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@higherkind sealed class KeyValueStore<A> : KeyValueStoreKind<A> { | |
companion object : FreeMonadInstance<KeyValueStoreHK> | |
} | |
data class Put<A>(val key: String, val value: A) : KeyValueStore<A>() | |
data class Get<A>(val key: String) : KeyValueStore<Option<A>>() | |
data class Delete(val key: String) : KeyValueStore<Unit>() | |
object Clear : KeyValueStore<Unit>() | |
typealias FreeKeyValueStore<A> = Free<KeyValueStoreHK, A> |