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

monocle.function.Field6.scala Maven / Gradle / Ivy

The newest version!
package monocle.function

import monocle.{Iso, Lens}

import scala.annotation.implicitNotFound

/** Typeclass that defines a [[Lens]] from an `S` to its sixth element of type `A`
  * @tparam S source of [[Lens]]
  * @tparam A target of [[Lens]], `A` is supposed to be unique for a given `S`
  */
@implicitNotFound(
  "Could not find an instance of Field6[${S},${A}], please check Monocle instance location policy to " + "find out which import is necessary"
)
@deprecated("use monocle.function.At.at(6)", since = "3.0.0-M1")
abstract class Field6[S, A] extends Serializable {
  def sixth: Lens[S, A]
}

trait Field6Functions {
  @deprecated("use monocle.function.At.at(6)", since = "3.0.0-M1")
  def sixth[S, A](implicit ev: Field6[S, A]): Lens[S, A] = ev.sixth
}

object Field6 extends Field6Functions {
  def apply[S, A](lens: Lens[S, A]): Field6[S, A] =
    new Field6[S, A] {
      override val sixth: Lens[S, A] = lens
    }

  /** lift an instance of [[Field6]] using an [[Iso]] */
  def fromIso[S, A, B](iso: Iso[S, A])(implicit ev: Field6[A, B]): Field6[S, B] =
    Field6(iso.andThen(ev.sixth))

  /** *********************************************************************************************
    */
  /** Std instances */
  /** *********************************************************************************************
    */
  implicit def tuple6Field6[A1, A2, A3, A4, A5, A6]: Field6[(A1, A2, A3, A4, A5, A6), A6] =
    Field6(
      Lens((_: (A1, A2, A3, A4, A5, A6))._6)(a => t => t.copy(_6 = a))
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy