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

monocle.std.BigInt.scala Maven / Gradle / Ivy

The newest version!
package monocle.std

import monocle.Prism

object bigint extends BigIntOptics

trait BigIntOptics {
  val bigIntToLong: Prism[BigInt, Long] =
    Prism[BigInt, Long](bi => if (bi.isValidLong) Some(bi.longValue) else None)(BigInt(_))

  val bigIntToInt: Prism[BigInt, Int] =
    bigIntToLong composePrism long.longToInt

  val bigIntToChar: Prism[BigInt, Char] =
    bigIntToLong composePrism long.longToChar

  val bigIntToByte: Prism[BigInt, Byte] =
    bigIntToLong composePrism long.longToByte

  val bigIntToBoolean: Prism[BigInt, Boolean] =
    bigIntToLong composePrism long.longToBoolean
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy