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

endless.core.data.EventsFolder.scala Maven / Gradle / Ivy

There is a newer version: 0.31.0
Show newest version
package endless.core.data

import cats.Foldable
import cats.syntax.foldable.*
import endless.\/
import endless.core.event.EventApplier

/** Convenience data type bundling state and event application (folding) function
  * @param state
  *   state value
  * @param applier
  *   event application function
  * @tparam S
  *   state
  * @tparam E
  *   event
  */
final case class EventsFolder[S, E](state: Option[S], applier: EventApplier[S, E]) {
  def applyOnFoldable[G[_]: Foldable](foldable: G[E]): String \/ Option[S] =
    foldable.foldM(state)(applier.apply)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy