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

tethys.cats.writers.CatsWriters.scala Maven / Gradle / Ivy

The newest version!
package tethys.cats.writers

import cats.data._
import tethys.JsonWriter

trait CatsWriters {
  implicit def writerForNev[T: JsonWriter]: JsonWriter[NonEmptyVector[T]] =
    JsonWriter[Vector[T]].contramap(_.toVector)

  implicit def writerForNel[T: JsonWriter]: JsonWriter[NonEmptyList[T]] =
    JsonWriter[List[T]].contramap(_.toList)

  implicit def writerForNes[T: JsonWriter]: JsonWriter[NonEmptySet[T]] =
    JsonWriter[Set[T]].contramap(_.toSortedSet)

  implicit def writerForChain[T: JsonWriter]: JsonWriter[Chain[T]] =
    JsonWriter[List[T]].contramap(_.toList)

  implicit def writerForNec[T: JsonWriter]: JsonWriter[NonEmptyChain[T]] =
    JsonWriter[Chain[T]].contramap(_.toChain)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy