arrow-fx / arrow.fx / MVarFactory

MVarFactory

interface MVarFactory<F>

Builds a MVar value for data types F without deciding the type of the MVar’s value.

import arrow.fx.*
import arrow.fx.extensions.io.concurrent.concurrent

fun main(args: Array<String>) {
  //sampleStart
  val mvarFactory: MVarFactory<ForIO> = MVar.factoryCancellable(IO.concurrent())
  val intVar: IOOf<MVar<ForIO, Int>> = mvarFactory.just(5)
  val stringVar: IOOf<MVar<ForIO, String>> = mvarFactory.empty<String>()
  //sampleEnd
}

Functions

empty Builds an empty MVar for type A.abstract fun <A> empty(): Kind<F, MVar<F, A>>
just Builds a MVar with a value of type A.abstract fun <A> just(a: A): Kind<F, MVar<F, A>>

Do you like Arrow?

Arrow Org
<