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

monocle.refined.bits.scala Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package monocle.refined

import monocle.function.At
import monocle.refined.internal.Bits

object bits extends BitsInstances

trait BitsInstances {

  implicit val byteAt: At[Byte, ByteBits, Boolean] = fromBits[Byte, ByteBits](_.get)
  implicit val charAt: At[Char, CharBits, Boolean] = fromBits[Char, CharBits](_.get)
  implicit val intAt : At[Int , IntBits , Boolean] = fromBits[Int , IntBits ](_.get)
  implicit val longAt: At[Long, LongBits, Boolean] = fromBits[Long, LongBits](_.get)

  def fromBits[S, I](toInt: I => Int)(implicit S: Bits[S]): At[S, I, Boolean] =
    At[S, I, Boolean](i => s => S.testBit(s, toInt(i)))(i => a => s => S.updateBit(a)(s, toInt(i)))

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy