given_Transform_Encoder

Extensions

Extensions

extension [A, B](fa: Encoder[A])
def exmap(f: A => Attempt[B], g: B => Attempt[A]): Encoder[B]

Inherited extensions

extension [A, B](fa: F[A])
def narrow(f: A => Attempt[B], g: B => A): Encoder[B]

Transforms supplied F[A] to an F[B] using two functions, A => Attempt[B] and B => A.

Transforms supplied F[A] to an F[B] using two functions, A => Attempt[B] and B => A.

The supplied functions form an injection from B to A. Hence, converting a F[A] to a F[B] converts from a larger to a smaller type. Hence, the name narrow.

Inherited from
Transform
extension [A, B](fa: F[A])
def widenOpt(f: A => B, g: B => Option[A]): Encoder[B]

Transforms supplied F[A] to an F[B] using two functions, A => B and B => Option[A].

Transforms supplied F[A] to an F[B] using two functions, A => B and B => Option[A].

Particularly useful when combined with case class apply/unapply. E.g., widenOpt(fa, Foo.apply, Foo.unapply).

Inherited from
Transform
extension [A, B](fa: F[A])
def xmap(f: A => B, g: B => A): Encoder[B]

Transforms supplied F[A] to an F[B] using the isomorphism described by two functions, A => B and B => A.

Transforms supplied F[A] to an F[B] using the isomorphism described by two functions, A => B and B => A.

Inherited from
Transform
extension [A, B](fa: F[A])
inline
def xmapc(f: A => B)(g: B => A): Encoder[B]

Curried version of xmap.

Curried version of xmap.

Inherited from
Transform
extension [A, B](fa: F[A])
def widen(f: A => B, g: B => Attempt[A]): Encoder[B]

Transforms supplied F[A] to an F[B] using two functions, A => B and B => Attempt[A].

Transforms supplied F[A] to an F[B] using two functions, A => B and B => Attempt[A].

The supplied functions form an injection from A to B. Hence, converting a F[A] to a F[B] converts from a smaller to a larger type. Hence, the name widen.

Inherited from
Transform