https://github.com/folone/scalaua
- 12 hours uploaded every minute
- ~35k listening years every month
-
125M tracks (including content from majors: Sony/Universal/Warner)
- ~170M monthly active users
^ quite unique: major labes and dark underground ^ 4x spotify audio (>1PB vs >5PB) ^ 10x smaller team than spotify ^ a lot more interactive, as in the next slide ^ by a huge margin bigger than any competitor in both usage and amount of data (collection size) ^ except for youtube: that's bigger, but they aren't in the audio business per se
^ war stories, we have some fun challenges due to the social nature of soundcloud ^ Drake vs Meek Mill
❤️
^ story about rails app ^ also clojure/jruby
👻
[fit] T-L-what now?1
^ TLC -- short for typelevel compiler. Name actively endorsed by Daniel Spiewak. ^ A scala fork made by the typelevel organization, to scratch an itch. ^ Typelevel Scala and the future of the Scala ecosystem
👻
^ Trying to work around partial type application, infering higher-order types: SI-2712
^ To recap: we’ve taken a few basic (but still pretty broken) Scala language features — singleton types, refinement types, type projections, and the implicit resolution system — and we’ve very painfully built a language for ourselves that at least kind of looks like it supports partial type parameter application, higher-order unification, and multiple implicit parameter sections.
-- Travis Brown
^ This is not what makes people come to scala ^ but it is what makes some of them stay with it
👻
^ For the people who miss pre 2.10 days ^ An incubator for new ideas ^ Beneficial for typesafe scala: they get battle-tested contributions ^ good news: scala will soon be perfect because of The Third System Effect ^ Note: we aren't compiler devs yet, we have full time jobs, and really don't know what we're doing. So don't take anything here as a promise or a final decision or anything that has any level of commitment. The whole point of this talk is to inspire collaboration. ^ Also don't rely on our support for the same set of reasons ^ Backwards compatibility with typesafe scala
^ sbt is awesome, works starting from 0.13.6 ^ 2.11.8-SNAPSHOT is published as well ^ 2.11.9-SNAPSHOT is published as well
- Type lambdas
@implicitAmbiguous
(coming to 2.12 #4673)- Singleton types
- -Zirrefutable-generator-patterns
- Nifties
trait Functor[F[_]] {
def map[A, B](fa: F[A])(fn: A => B): F[B]
}
trait LeftFunctor[R] extends
Functor[({type U[x] = Either[x, R]})#U]
trait RightFunctor[L] extends
Functor[[y] => Either[L, y]]
[x] => (x, x)
[x, y] => (x, Int) => y
[x[_]] => x[Double]
[+x, -y] => Function1[y, x]
-- Paul Phillips (SI-6895)
@implicitAmbiguous
2
// Encoding for "A is not a subtype of B"
trait <:!<[A, B]
// Uses ambiguity to rule out the cases we're trying to exclude
implicit def nsub[A, B] : A <:!< B = null
@typelevel.annotation.implicitAmbiguous("Returning ${B} is forbidden.")
implicit def nsubAmbig1[A, B >: A] : A <:!< B = null
implicit def nsubAmbig2[A, B >: A] : A <:!< B = null
// Type alias for context bound
type |¬|[T] = {
type λ[U] = U <:!< T
}
def foo[T, R : |¬|[Unit]#λ](t: T)(f: T => R) = f(t)
foo(23)(_ + 1) // OK
foo(23)(println) // Doesn't compile: "Returning Unit is forbidden."
Singleton types3
trait Assoc[K] { type V ; val v: V }
def mkAssoc[K, V0](k: K, v0: V0): Assoc[k.type] { type V = V0 } =
new Assoc[k.type] {type V = V0 ; val v = v0}
def lookup[K](k: K)(implicit a: Assoc[k.type]): a.V = a.v
^ Adriaan's implementation
implicit def firstAssoc = mkAssoc(1, "Panda!")
//> firstAssoc : Assoc[Int(1)]{type V = String}
implicit def secondAssoc = mkAssoc(2, 2.0)
//> secondAssoc : Assoc[Int(2)]{type V = Double}
implicit def ageAssoc = mkAssoc("Age", 3)
//> ageAssoc : Assoc[String("Age")]{type V = Int}
implicit def nmAssoc = mkAssoc("Name", "Jane")
//> nmAssoc : Assoc[String("Name")]{type V = String}
lookup(1)
// > res1: String = Panda!
lookup(2)
// > res2: Double = 2.0
lookup("Age")
// > res3: Int = 3
lookup("Name")
// > res4: String = Jane
for {
(x, _) <- Option((1, 2))
} yield x
Some(scala.Tuple2(1, 2))
.withFilter(((check$ifrefutable$1) =>
check$ifrefutable$1: @scala.unchecked match {
case scala.Tuple2((x @ _), _) => true
case _ => false
})).map(((x$1) => x$1: @scala.unchecked match {
case scala.Tuple2((x @ _), _) => x
}))
Some(scala.Tuple2(1, 2)).map(((x$1) => x$1 match {
case scala.Tuple2((x @ _), _) => x
}))
^ This has a few practical differences:
^ Without the flag, non-matching values will be filtered out
^ With the flag, partial patterns will trigger a warning and scala.MatchError could be thrown at runtime (e.g (x, 1) <- Option((1, 2))
)
^ Without the flag, you can't have patterns on the left hand side unless the right hand side has withFilter
^ With the flag, desugaring generators in for-comprehension only needs flatMap and map; withFilter is used only for desugaring if.
def fib(n: Int) = {
def fib'(n: Int, next: Int, £: Int): Int =
n match {
case 0 => £
case _ => fib'(n - 1, next + £, next)
}
fib'(n, 1, 0)
}
val £': Byte = 127z
^ Mention some nifty things added to the fork
💉 🗻
^ no releases of 2.10 ^ will soon drop 2.11, 2.12 only ^ once dotty bootstraps, will switch to it (dotty is the Third System Effect) ^ point is being on the bleeding edge ^ as you can see, we're mostly adding small things and battle-testing them ^ no one one of us is a compiler engineer ^ eventually we plan to get better at compiler development, and work on bigger, more impactful features ^ not to split the community ^ compiler plugin?
- converting partest tests to junit
- documentation
- Reporting bugs
- Fixing bugs
- Backporting changes from typesafe scala
^ Don't over-promise ^ Note: we aren't compiler devs yet, we have full time jobs, and really don't know what we're doing. So don't take anything here as a promise or a final dicision or anything that has any level of commitement. The whole point of this talk is to inspire collaboration. ^ This is just an exploration of possible ideas, no commitments, etc. ^ Никаких коммитментов, только фантазии
^ can base them on top of literal-based singleton types ^ going to an external SMT like z3 to prove things about types ^ talked about this last year at scala.exchange ^ generally relying on something external to figure out types would allow us to get the benifits of external research for free as well
val x: 7.type = 7
val x: (t => 7).type = 7
val x: (t => t < 10 && t > 5).type = 7
^ Ammonite repl
Rethinking the role of implicits4
There's a Prolog in your Scala: http://j.mp/prolog-scala-talk
^ Adriaan's presentation
scalaVersion := "2.11.7"
scalaOrganization := "org.typelevel"
^ compiled shapeless and cats with this ^ also works with scala.js ^ who has a project that's 2.11 only?
sbt compile
sbt test
sbt partest
^ Compiling from scratch ~5mins
^ ant билд - legacy
^ sbt publish-local
^ sbt test
~3 minutes
^ sbt partest
~1 hour
^ Beneficial for typesafe and typelevel ^ No community splitting ^ Bleeding edge ^ Try now, contribute ^ We'll be reviving the project, marking low-hanging fruit tasks, etc.
@folone
Footnotes
-
requeires
-Xexperimental
flag ↩ -
https://github.com/typelevel/scala/issues/28 --
@implicitWeight
↩