Skip to content

Instantly share code, notes, and snippets.

@janekdb
janekdb / gist:7d9b7a1f09dc8ce562a2
Created March 18, 2016 13:55
Local failure of `$ ant test` with scala/scala PR5049
BUILD FAILED
/home/jdb/workspaces/public/scala/build.xml:1495: The following error occurred while executing this line:
/home/jdb/workspaces/public/scala/build-ant-macros.xml:776: Test suite finished with 2 cases failing:
fail - run/origins.scala [output differs]% scalac origins.scala
% /usr/lib/jvm/java-8-oracle/jre/bin/java \
-Xms1536M \
-Xmx1536M \
-Xss1M \
-XX:+UseParallelGC \
-classpath \
@janekdb
janekdb / gist:d59ab2c679a1e6710b5e
Created March 21, 2016 16:38
Remove Predef.error: Preremoval build failure
BUILD FAILED
/home/jdb/workspaces/public/scala/build.xml:1495: The following error occurred while executing this line:
/home/jdb/workspaces/public/scala/build-ant-macros.xml:776: Test suite finished with 2 cases failing:
fail - run/origins.scala [output differs]% scalac origins.scala
% /usr/lib/jvm/java-8-oracle/jre/bin/java \
-Xms1536M \
-Xmx1536M \
-Xss1M \
-XX:+UseParallelGC \
-classpath \
BUILD FAILED
/home/jdb/workspaces/public/scala/build.xml:1495: The following error occurred while executing this line:
/home/jdb/workspaces/public/scala/build-ant-macros.xml:776: Test suite finished with 1 case failing:
fail - run/origins.scala [output differs]% scalac origins.scala
% /usr/lib/jvm/java-8-oracle/jre/bin/java \
-Xms1536M \
-Xmx1536M \
-Xss1M \
-XX:+UseParallelGC \
-classpath \
@janekdb
janekdb / gist:cd5b30dbb33de5fb6e766c1ba1f9eb6e
Last active January 31, 2017 22:48
Not importing implicitConversions does not prevent compilation
### With import, without -feature flag: Compiles: YES
$ cat D.scala
import language.implicitConversions
object D {
implicit def i2s(i: Int): String = (i - 1).toString
val num: String = 44
--- build/spec/07-implicits.html 2017-02-17 19:59:29.867811207 +0000
+++ build-spec-2.5.3/07-implicits.html 2017-02-17 19:58:10.555811809 +0000
@@ -113,20 +113,20 @@
<p>The following code defines an abstract class of monoids and
two concrete implementations, <code>StringMonoid</code> and
<code>IntMonoid</code>. The two implementations are marked implicit.</p>
-<div class="highlight"><pre><code class="language-scala" data-lang="scala"><span class="k">abstract</span> <span class="k">class</span> <span class="nc">Monoid</span><span class="o">[</span><span class="kt">A</span><span class="o">]</span> <span class="nc">extends</span> <span class="nc">SemiGroup</span><span class="o">[</span><span class="kt">A</span><span class="o">]</span> <span class="o">{</span>
- <span class="k">def</span> <span class="n">unit</span><span class="k">:</span> <span class="kt">A</span>
- <span class="k">def</span> <span class="n">add</span><span class="o">(</span><span class="n">x</span><span class="k">:</span> <span class="kt">
@janekdb
janekdb / type-level-programming-natural-numbers.scala
Last active June 11, 2017 20:48
Scala Type Level Programming: The Natural Numbers
sealed trait MsbZero extends Nat {
override type inc = MsbOne
override type dbl = MsbZero
override type half = MsbZero
override type add[That <: Nat] = That
override type coreT[That <: Nat] = B0[That]
override type mult[That <: Nat] = MsbZero
override type exp[That <: Nat] = MsbZero
override type expflip[That <: Nat] = MsbOne
}
@janekdb
janekdb / type-level-programming-natural-numbers-mult.scala
Last active June 11, 2017 20:50
Scala Type Level Programming: The Natural Numbers: Multiplication
sealed trait Nat {
type mult[That <: Nat] <: Nat
}
sealed trait MsbZero extends Nat {
override type mult[That <: Nat] = MsbZero
}
sealed trait MsbOne extends Nat {
override type mult[That <: Nat] = That
@janekdb
janekdb / type-level-programming-natural-numbers-mult-assert.scala
Last active June 11, 2017 21:07
Scala Type Level Programming: The Natural Numbers: Multiplication Assertions
implicitly[MsbZero#mult[MsbZero] =:= MsbZero]
implicitly[MsbZero#mult[MsbOne] =:= MsbZero]
implicitly[MsbOne#mult[MsbZero] =:= MsbZero]
implicitly[MsbOne#mult[MsbOne] =:= MsbOne]
implicitly[T0#mult[T0] =:= T0]
implicitly[T0#mult[T2] =:= T0]
implicitly[T0#mult[T4] =:= T0]
implicitly[T1#mult[T0] =:= T0]
@janekdb
janekdb / type-level-programming-natural-numbers-mult-example.scala
Created May 23, 2017 10:31
Scala Type Level Programming: The Natural Numbers: Multiplication Example
// 2 x 3 5 x 7 x 11 x 13 x 17 = 510510
type T510 = T5#mult[T10]#add[T1]#mult[T10]
type T510510 = T510#mult[T1000]#add[T510]
implicitly[T2#mult[T3]#mult[T5]#mult[T7]#mult[T11]#mult[T13]#mult[T17] =:= T510510]
@janekdb
janekdb / type-level-programming-natural-numbers-first-definitions.scala
Last active June 11, 2017 21:02
Scala Type Level Programming: The Natural Numbers: First Definitions
sealed trait Nat {
type inc <: Nat
type dbl <: Nat
}
sealed trait MsbZero extends Nat {
override type inc = MsbOne
override type dbl = MsbZero
}