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

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

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

import arrow.optics.Setter
import io.lamart.lux.Mutable

interface FocusedSetter : Focused {
    val setter: Setter

    fun set(focus: A) = source.modify { setter.set(it, focus) }

    fun modify(map: (focus: A) -> A) = source.modify { setter.modify(it, map) }

    fun  compose(other: Setter): FocusedSetter {
        return object : FocusedSetter {
            override val source: Mutable = [email protected]
            override val setter: Setter = [email protected](other)
        }
    }

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

}