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

scalaz.undo.History.scala Maven / Gradle / Ivy

The newest version!
package org.specs2.internal.scalaz
package undo

case class History[S](current: S, undos: List[S] = Nil, redos: List[S] = Nil)

trait HistoryInstances {
  implicit def history: Functor[History] = new Pointed[History] {
    def map[A, B](fa: History[A])(f: (A) => B): History[B] = History(f(fa.current), fa.undos.map(f), fa.redos.map(f))

    def point[A](a: => A): History[A] = History(a)
  }

  implicit def historyShow[S](implicit SL: Show[List[S]], S: Show[S]) = new Show[History[S]] {
    override def show(a: History[S]) =
      Cord("History(", S.show(a.current), ",", SL.show(a.undos), ",", SL.show(a.redos), ")")
  }
}

object History extends HistoryInstances




© 2015 - 2025 Weber Informatics LLC | Privacy Policy