Packages

trait Transducer[Output] extends AnyRef

A Transducer represents an animation that starts in some initial state and proceeds through various states until it stops. For example, a square might move from an x position of 0 to an x position of 100 in increments of 10. The states then become 0, 10, 20, ..., 100.

More abstractly, a transducer is a finite state machine with an additional set of output values, so that each state is associated with some output value. Continuing the example of the moving square, the states are the x position and the output is the square at the given position (for some fixed y coordinate).

Transducers should be treated like half open intervals, which means they should generate the inital state but avoid generating a stopping state when possible (for example, when combined in sequence with another transducer).

Transducers have several type classes instances:

  • Traverse
  • Applicative
  • Monoid, corresponding to sequential composition (++)

The majority of the API is provided by the Cats methods defined on these type classes, so import cats.implicits._ to get a richer API (e.g. toList, filter, etc.)

There is another possible monoid, which corresponds to parallel composition (and), if there is a monoid on the type A. Taken with ++ this makes Transducers a Rig or Semiring (depending on how one defines these terms; they are not always defined in the same way).

Self Type
Transducer[Output]
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Transducer
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract type State

    The type of the state used by this transducer.

    The type of the state used by this transducer. A type parameter as this isn't really needed outside of the transducer.

Abstract Value Members

  1. abstract def initial: State

    The initial state for this Transducer.

  2. abstract def next(current: State): State

    A method that constructs the next state given the current state.

    A method that constructs the next state given the current state. If the current state is a stopped state this method should always return that state.

  3. abstract def output(state: State): Output

    A method that returns the output of the current state.

    A method that returns the output of the current state. If the transducer has stopped it may not have any output, in which case it can throw a java.util.NoSuchElementException. As a result, clients should avoid calling this method when the transducer is in a stopped state. If possible this method should return some other sensible result, rather than throwing an exception, if given a stopped state.

  4. abstract def stopped(state: State): Boolean

    True if this state is a stopped (or halt) state, meaning the transducer will never transition to a different state.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def ++(that: Transducer[Output]): Transducer[Output]

    Append that transducer to this transducer, so that tranducer runs when this one has finished.

    Append that transducer to this transducer, so that tranducer runs when this one has finished. Both transducers must produce output of the same type.

  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. def and(that: Transducer[Output])(implicit m: Monoid[Output]): Transducer[Output]

    Create a transducer that runs this transducer in parallel with that transducer, stopping when both have stopped.

    Create a transducer that runs this transducer in parallel with that transducer, stopping when both have stopped. Both transducers must produce output of the same type, and there must be a monoid instance for the output type.

    If one transducer stops before the other then its last output before stopping is returned as its output until the other transducer stops. If it stops before generating output (i.e. its initial state is a stopping state) than the zero / identity of the monoid is used as its output. This behaviour is usually what we want for animations, and it makes and a monoid instance for transducer with empty as the identity. To stop when either have stopped see product.

  6. def andThen(f: (Output) ⇒ Transducer[Output]): Transducer[Output]

    When this transducer's next state would be a stopped state, transition to the tranducer created by calling the given function with the current output.

    When this transducer's next state would be a stopped state, transition to the tranducer created by calling the given function with the current output. If this transducer immediately stops, and hence has no output, there will be no output to pass to the function and therefore the next transducer will not be created.

    This is like append (++) but allows the final output to determine the transducer that is appended.

  7. def animate[Alg[x[_]] <: Algebra[x[_]], F[_], Frame, Canvas](frame: Frame)(implicit a: AnimationRenderer[Canvas], e: Renderer[Alg, F, Frame, Canvas], r: Redraw[Canvas], s: Scheduler, ev: <:<[Output, Picture[Alg, F, Unit]]): Unit

    Convenience method to animate a transducer.

  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. def foldLeft[B](zero: B)(f: (B, Output) ⇒ B): B
  14. def foldRight[B](zero: Eval[B])(f: (Output, Eval[B]) ⇒ Eval[B]): Eval[B]
  15. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def map[B](f: (Output) ⇒ B): Transducer[B]

    Transform the output of this transducer using the given function

  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. def product[B](that: Transducer[B]): Transducer[(Output, B)]

    Create a transducer that runs this transducer in parallel with that transducer, stopping when either has stopped.

    Create a transducer that runs this transducer in parallel with that transducer, stopping when either has stopped. To stop when both have stopped see and.

  23. def repeat(count: Int): Transducer[Output]

    Construct a transducer by appending this transducer to itself the given number of times.

    Construct a transducer by appending this transducer to itself the given number of times.

    The count must be 0 or greater.

  24. def repeatForever: Transducer[Output]
  25. def scanLeft[B](zero: B)(f: (B, Output) ⇒ B): Transducer[B]

    Create a transducer that outputs the cumulative results of applying the function f to the output of the underlying transducer.

    Create a transducer that outputs the cumulative results of applying the function f to the output of the underlying transducer. If the underlying transducer has stopped the zero value is produced as the only output.

  26. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  27. def toObservable: Observable[Output]

    Convert this transducer to an monix.reactive.Observable

  28. def toString(): String
    Definition Classes
    AnyRef → Any
  29. def traverse[G[_], B](f: (Output) ⇒ G[B])(implicit G: Applicative[G]): G[Transducer[B]]
  30. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped