Skip to content

Instantly share code, notes, and snippets.

Grzegorz Kossakowski gkossakowski

Block or report user

Report or block gkossakowski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gkossakowski
gkossakowski / A.java
Created Nov 26, 2018
Scala vs Java compilation speed experiment
View A.java
class A1 {
String f1(String x) { return x; }
String f2(String x) { return x; }
.
.
String f100(String x) { return x; }
}
@gkossakowski
gkossakowski / completers_awkward_code_pattern.scala
Created Dec 22, 2016
An example of an awkward code pattern caused by interruptible completers
View completers_awkward_code_pattern.scala
val resolvedParents = new util.ArrayList[Type]()
var remainingParents = tmpl.parents
while (remainingParents.nonEmpty) {
val parent = remainingParents.head
val resolved = resolveTypeTree(parent, lookupScope)
// this is awkard and highly repetitive pattern
resolved match {
case CompletedType(tpe) => resolvedParents.add(tpe)
case _: IncompleteDependency | NotFound => return resolved
}
@gkossakowski
gkossakowski / Interruptible_completer.scala
Last active Jan 24, 2018
Definition of an Interruptible completer
View Interruptible_completer.scala
sealed trait Result[T]
case class CompletedResult[T](value: T) extends Result[T]
case class IncompleteDependency(dep: Symbol) extends Result[T]
// completer is:
() => Result[T]
@gkossakowski
gkossakowski / leaky_completer.scala
Created Dec 22, 2016
An example of a leaky type completer in Dotty
View leaky_completer.scala
// Ensure constructor is completed so that any parameter accessors
// which have type trees deriving from its parameters can be
// completed in turn. Note that parent types access such parameter
// accessors, that's why the constructor needs to be completed before
// the parent types are elaborated.
index(constr)
annotate(constr :: params)
symbolOfTree(constr).ensureCompleted()
View wykladniczy_trening.txt
| Tydzień | Dystans km | Przyrost % | Przyrost 7% = km |
|---------|------------|------------|------------------|
| 1 | 30 | 7% | 2,1 |
| 2 | 32,1 | 7% | 2,24 |
| 5 | 36,75 | 7% | 2,57 |
| 10 | 59 | 7% | 4,13 |
| 15 | 82,77 | 7% | 5,79 |
| 20 | 116 | 7% | 8,12 |
|------------------------------------------------------|
| 25 | 162,82 | 7% | 11,39 |
@gkossakowski
gkossakowski / asSeenFrom.md
Last active Jun 19, 2018
Understand Scala's core typechecking rules
View asSeenFrom.md

Scala's "type T in class C as seen from a prefix type S" with examples

Introduction

Recently, I found myself in need to precisely understand Scala's core typechecking rules. I was particulary interested in understanding rules responsible for typechecking signatures of members defined in classes (and all types derived from them). Scala Language Specification (SLS) contains definition of the rules but lacks any examples. The definition of the rules uses mutual recursion and nested switch-like constructs that make it hard to follow. I've written down examples together with explanation how specific set of rules (grouped thematically) is applied. These notes helped me gain confidence that I fully understand Scala's core typechecking algorithm.

As Seen From

Let's quote the Scala spec for As Seen From (ASF) rules numbered for an easier reference:

View gist:ac188d48865f73c7d7bf
### Keybase proof
I hereby claim:
* I am gkossakowski on github.
* I am grek (https://keybase.io/grek) on keybase.
* I have a public key whose fingerprint is F784 54E6 6DA3 D66C 89D2 C01E 287A 9033 977D BF9C
To claim this, I am signing this object:
@gkossakowski
gkossakowski / fetchTweets.js
Last active Aug 29, 2015
Asynchronous fetching of tweets from Twitter
View fetchTweets.js
function fetchTweets(username, callback) {
jQuery.ajax({
url: "http://api.twitter.com/1/
statuses/user_timeline.json/",
type: "GET",
dataType: "jsonp",
data: {
screen_name : username,
include_rts : true,
count : 5,
@gkossakowski
gkossakowski / sbteclipse-settings.patch
Last active Aug 29, 2015
Patch needed to generate proper Eclipse files for sbt project itself
View sbteclipse-settings.patch
diff --git a/project/Sbt.scala b/project/Sbt.scala
index 4e660f4..8007c3b 100644
--- a/project/Sbt.scala
+++ b/project/Sbt.scala
@@ -8,6 +8,8 @@ import Common._
import Licensed._
import Scope.ThisScope
import LaunchProguard.{ proguard, Proguard }
+import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys
+import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseCreateSrc
View gist:11291128
Greks-MBP:uber-build grek (test/new-zinc-script2)$ git diff
diff --git a/config/nightly-4.0.x-juno-2.11.conf b/config/nightly-4.0.x-juno-2.11.conf
index 27de8cd..f115399 100644
--- a/config/nightly-4.0.x-juno-2.11.conf
+++ b/config/nightly-4.0.x-juno-2.11.conf
@@ -37,12 +37,12 @@ BUILD_TYPE=dev
##### Scala information #####
SCALA_GIT_REPO=git://github.com/scala/scala
# The version of Scala to use
-SCALA_VERSION=2.11.0-SNAPSHOT
You can’t perform that action at this time.