Tagged

data class Tagged<A, B>(val value: B) : K3<Tagged.T, Unit, A, B> (source)

A value of type B tagged with a phantom input type A, viewed as a profunctor.

Running an optic on a Tagged builds the whole from a focus: it is the profunctor behind reverseGet. Encoded as K3 with a phantom Unit, like Function1.

Instances: TaggedProfunctor, TaggedChoice, TaggedClosed, TaggedCostrong.

val choice = object : TaggedChoice {}
Tagged.narrow(choice.left<Int, Int, String>(Tagged(1))).value // Left(1)

Constructors

Link copied to clipboard
constructor(value: B)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class T

Witness type used to encode Tagged as a higher-kinded K3<Tagged.T, Unit, A, B>.

Properties

Link copied to clipboard
val value: B

the carried value.

Functions

Link copied to clipboard
infix fun <C> fmap(f: (B) -> C): Tagged<A, C>

Maps the carried value.

Link copied to clipboard
fun <C> retag(): Tagged<C, B>

Changes the phantom input type.