http://stackoverflow.com/questions/17708489/using-kafka-as-a-cqrs-eventstore-good-idea
- > What happens when you add a new model... ?
http://stackoverflow.com/questions/17708489/using-kafka-as-a-cqrs-eventstore-good-idea
Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * xThis is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere… I hope to present the information you need without assuming anything.
Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!
One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.
git remote add upstream https://github.com/whoever/whatever.git
git fetch upstream
| // Based on following links: | |
| // http://andrew.hedges.name/experiments/haversine/ | |
| // http://www.movable-type.co.uk/scripts/latlong.html | |
| df | |
| .withColumn("a", pow(sin(toRadians($"destination_latitude" - $"origin_latitude") / 2), 2) + cos(toRadians($"origin_latitude")) * cos(toRadians($"destination_latitude")) * pow(sin(toRadians($"destination_longitude" - $"origin_longitude") / 2), 2)) | |
| .withColumn("distance", atan2(sqrt($"a"), sqrt(-$"a" + 1)) * 2 * 6371) | |
| >>> | |
| +--------------+-------------------+-------------+----------------+---------------+----------------+--------------------+---------------------+--------------------+------------------+ | |
| |origin_airport|destination_airport| origin_city|destination_city|origin_latitude|origin_longitude|destination_latitude|destination_longitude| a| distance| |
Tageless Final interpreters are an alternative to the traditional Algebraic Data Type (and generalized ADT) based implementation of the interpreter pattern. This document presents the Tageless Final approach with Scala, and shows how Dotty with it's recently added implicits functions makes the approach even more appealing. All examples are direct translations of their Haskell version presented in the Typed Tagless Final Interpreters: Lecture Notes (section 2).
The interpreter pattern has recently received a lot of attention in the Scala community. A lot of efforts have been invested in trying to address the biggest shortcomings of ADT/GADT based solutions: extensibility. One can first look at cats' Inject typeclass for an implementation of [Data Type à la Carte](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesA
| import scala.collection.mutable.ListBuffer | |
| object implicex { | |
| trait ImplicitFunction1[-A, +B] { | |
| def apply()(implicit a: A): B | |
| } | |
| def fn[A, B](f: A => B): ImplicitFunction1[A, B] = new ImplicitFunction1[A, B] { | |
| def apply()(implicit a: A): B = f(a) | |
| } |
| import scalanative.native._ | |
| import SDL._ | |
| import SDLExtra._ | |
| @extern | |
| @link("SDL2") | |
| object SDL { | |
| type Window = CStruct0 | |
| type Renderer = CStruct0 |
| import monix.eval.Task | |
| import java.util.concurrent.TimeUnit | |
| import scala.concurrent.duration._ | |
| /** Request limiter for APIs that have quotas per second, minute, hour, etc. | |
| * | |
| * {{{ | |
| * // Rate-limits to 100 requests per second | |
| * val limiter = TaskLimiter(TimeUnit.SECONDS, limit = 100) | |
| * |
| scalaVersion := "2.11.8" | |
| scalaOrganization := "org.typelevel" | |
| libraryDependencies ++= Seq( | |
| "org.typelevel" %% "cats" % "0.9.0", | |
| "org.atnos" %% "eff" % "4.0.0" | |
| ) | |
| addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.3") |