Skip to content

Instantly share code, notes, and snippets.

@camjo
camjo / PrototypeAPIStream.scala
Created August 25, 2018 03:45
Another example API (less complete) based on the beam model where everything is streams and tables
// Following model based on the description of
// Apache Beam in the book Streaming Systems by Reuven Lax; Tyler Akidau; Slava Chernyak
/**
* Tables are data at rest, and act as a container for data to accumulate and be observed over time.
* K = Key
* V = Value
* W = Window
* P = Partition
*/
@camjo
camjo / PrototypeAPI.scala
Created August 24, 2018 12:59
Experimenting with a batch/streams API for scalaz-analytics
// Note that this is written in terms of functions for now. We will rewrite this with arrows etc
// and work out the reified encoding once we agree on the API
/**
* At a high level, there are two core concepts here
* 1. Data
* 2. Computation
*
* The Data can be thought of as Bounded or Unbounded.
* This generally corresponds to a "batch" source or a "streaming" source.
@camjo
camjo / PlotInput.scala
Created June 28, 2018 10:00
Data structure independent plotting
import scalaz.effect.IO
trait Source[F[_], A] {
def iterator(s: F[A]): Iterator[A]
}
object Source {
implicit def listSource[A]: Source[List, A] = (s: List[A]) => s.toIterator
implicit def streamSource[A]: Source[Stream, A] = (s: Stream[A]) => s.toIterator
}
import scalaz.{-\/, Applicative, Coproduct, Free, FreeAp, Inject, Monad, NaturalTransformation, Nondeterminism, \/-, ~>}
import scala.language.{higherKinds, reflectiveCalls}
import scalaz.concurrent.Task
import Task._
import scala.util.Random
case class User(name: String, age: Int)
sealed trait UserOperation[T]
case class CreateUser(name: String, age: Int) extends UserOperation[User]