Packages

p

circelib

package circelib

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Package Members

  1. package helpers

Value Members

  1. object ADTSection extends AnyFlatSpec with Matchers with Section

    The most straightforward way to encode / decode ADTs is by using generic derivation for the case classes but explicitly defined instances for the ADT type.

    ADTs encoding and decoding

    The most straightforward way to encode / decode ADTs is by using generic derivation for the case classes but explicitly defined instances for the ADT type.

  2. object CirceLibrary extends Library

    circe (pronounced SUR-see, or KEER-kee in classical Greek) is a JSON library for Scala (and Scala.js).

  3. object CustomCodecsSection extends AnyFlatSpec with Matchers with Section

    If you want to write your own codec instead of using automatic or semi-automatic derivation, you can do so in a couple of ways.

    Custom encoders/decoders

    If you want to write your own codec instead of using automatic or semi-automatic derivation, you can do so in a couple of ways.

    Firstly, you can write a new Encoder[A] and Decoder[A] from scratch

    class Thing()
    
    implicit val encodeFoo: Encoder[Thing] = new Encoder[Thing] {
       final def apply(a: Thing): Json = ??? // your implementation goes here
    }
    
    implicit val decodeFoo: Decoder[Thing] = new Decoder[Thing] {
       final def apply(c: HCursor): Decoder.Result[Thing] = Left(DecodingFailure("Not implemented yet", c.history))
    }

    But in many cases you might find it more convenient to piggyback on top of the decoders that are already available. For example, a codec for java.time.Instant might look like this:

    import cats.syntax.either._
    
    import java.time.Instant
    
    implicit val encodeInstant: Encoder[Instant] = Encoder.encodeString.contramap[Instant](_.toString)
    
    implicit val decodeInstant: Decoder[Instant] = Decoder.decodeString.emap { str =>
       Either.catchNonFatal(Instant.parse(str)).leftMap(t => "Instant")
    }
  4. object EncodingDecodingSection extends AnyFlatSpec with Matchers with Section

  5. object JsonSection extends AnyFlatSpec with Matchers with Section

  6. object OpticsSection extends AnyFlatSpec with Matchers with Section

  7. object TraversingSection extends AnyFlatSpec with Matchers with Section

Ungrouped