All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.lamart.lux.focus.FocusedOptional.kt Maven / Gradle / Ivy

There is a newer version: 0.5.2
Show newest version
package io.lamart.lux.focus

import arrow.core.Either
import arrow.optics.Optional
import arrow.optics.Setter
import io.lamart.lux.Mutable

interface FocusedOptional : Focused, FocusedSetter {
    val optional: Optional

    fun getOrModify(): Either = optional.getOrModify(source.get())

    fun  compose(other: Optional): FocusedOptional {
        val optional = [email protected](other)

        return object : FocusedOptional {
            override val source: Mutable = [email protected]
            override val optional: Optional = optional
            override val setter: Setter = optional
        }
    }

    operator fun  plus(other: Optional) = compose(other)

}