data.Notification.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of skunk-core_2.12 Show documentation
Show all versions of skunk-core_2.12 Show documentation
Tagless, non-blocking data access library for Postgres.
The newest version!
// Copyright (c) 2018-2021 by Rob Norris
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT
package skunk
package data
import cats._
import cats.syntax.all._
final case class Notification[A](pid: Int, channel: Identifier, value: A) {
def map[B](f: A => B): Notification[B] = copy(value = f(value))
}
object Notification {
implicit val TraverseNotification: Traverse[Notification] =
new Traverse[Notification] {
def foldLeft[A, B](fa: Notification[A], b: B)(f: (B, A) => B): B = f(b, fa.value)
def foldRight[A, B](fa: Notification[A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B] = f(fa.value, lb)
def traverse[G[_]: Applicative, A, B](fa: Notification[A])(f: A => G[B]): G[Notification[B]] = f(fa.value).map(b => fa.copy(value = b))
override def map[A, B](fa: Notification[A])(f: A => B): Notification[B] = fa.map(f)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy