Divisible

beginner

Divisible extends upon Divide by providing an empty method called conquer. conquer is useful to prove identiy laws when working with Divisible instances.

Extending the serializer example from Divide conquer would simply serialize data to an empty string.


import arrow.Kind
import arrow.core.Tuple2
import arrow.core.toT
import com.example.domain.*

fun main(args: Array<String>) {
  //sampleStart
   val emptySerializer: SerializerOf<Int> = Serializer.divisible().conquer()

  val result = emptySerializer.fix().func(1)
  //sampleEnd
  println(result)
}

Main Combinators

conquer

Construct an empty value for any Kind<F, A>.

Laws

Arrow provides DivisibleLaws in the form of test cases for internal verification of lawful instances and third party apps creating their own Divisible instances.

See Deriving and creating custom typeclass to provide your own Divisible instances for custom datatypes.

Data types

Module Data types
arrow.mtl EitherT, Kleisli, OptionT, StateT, WriterT
arrow.typeclasses Const, Conested
arrow.ui Sum

Type Class Hierarchy