Below are the sources I took notes and hope to learn about Cake Pattern from.
Videos:
Below are the sources I took notes and hope to learn about Cake Pattern from.
Videos:
Now that we live in the Big Data, Web 3.14159 era, lots of people want to build databases that are too big to fit on a single machine. But there's a problem in the form of the CAP theorem, which states that if your network ever partitions (a machine goes down, or part of the network loses its connection to the rest) then you can keep consistency (all machines return the same answer to
Context Bounds это синтаксических сахар для неявного списка параметров. Например, такой код
def foo[A : B : C](a: A)
не что иное как
def foo[A](a: A)(implicit evidence: B[A], C[A])
Если есть множественные границы контекста численностью от 1 до N, то они будут транслироваться в один список, как показано выше.
trait %>[From, To] { | |
def apply(x: From): To | |
} | |
def view[From, To](f: From => To): From %> To = | |
new %>[From, To] { | |
def apply(x: From): To = f(x) | |
} | |
implicit i: Int %> String = view(_.toString) |
import scalaz._ | |
import scalaz.std.list._ | |
import scalaz.syntax.monad._ | |
import scalaz.syntax.monoid._ | |
import scalaz.syntax.traverse.{ToFunctorOps => _, _} | |
class Foo[F[+_] : Monad, A, B](val execute: Foo.Request[A] => F[B], val joins: Foo.Request[A] => B => List[Foo.Request[A]])(implicit J: Foo.Join[A, B]) { | |
def bar: Foo[({type l[+a]=WriterT[F, Log[A, B], a]})#l, A, B] = { | |
type TraceW[FF[+_], +AA] = WriterT[FF, Log[A, B], AA] |
Have you ever had to write code that made a complex series of succesive modifications to a single piece of mutable state? (Almost certainly yes.)
Did you ever wish you could make the compiler tell you if a particular operation on the state was illegal at a given point in the modifications? (If you're a fan of static typing, probably yes.)
If that's the case, the indexed state monad can help!
Motivation
The indexed state monad is not the only indexed monad out there; it's not even the only useful one. In this tutorial, we will explore another indexed monad, this time one that encapsulates the full power of delimited continuations: the indexed continuation monad.
The relationship between the indexed and regular state monads holds true as well for the indexed and regular continuation monads, but while the indexed state monad allows us to keep a state while changing its type in a type-safe way, the indexed continuation monad allows us to manipulate delimited continuations while the return type of the continuation block changes arbitrarily. This, unlike the regular continuation monad, allows us the full power of delimited continuations in a dynamic language like Scheme while still remaining completely statically typed.
/** | |
* @author Alexander Krasniansky | |
*/ | |
object Product extends App { | |
def cardinality(set: Set[_]) = set size | |
// ================= Set Intersection ================= | |
val A = Set(1, 2, 3, 4, 5) |
trait A { | |
def foo() | |
} | |
trait B { | |
def bar() | |
} | |
trait C { | |
self: A with B => |