This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** TL;DR Of course we want to savagely truncate our data! | |
* You know we want that because earlier you saw us cast between | |
* same-sized types (because you offer no other way) and all casts | |
* are the same. | |
*/ | |
package main | |
import . "fmt" | |
type Foo int16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env scalas | |
/*** | |
scalaVersion := "2.11.7" | |
libraryDependencies += "com.typesafe.play" %% "play-netty-server" % "2.4.6" | |
*/ | |
import play.core.server._ | |
import play.api.routing.sird._ | |
import play.api.mvc._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lo/hi | |
enc/dec | |
fst/snd | |
get/put/del | |
new/add/mod/del/(rem) | |
old/new | |
req/rsp | |
src/dst | |
usr/pwd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from abc import ABCMeta, abstractmethod | |
import sys | |
# lets get one thing straight right out of the box: | |
def fail(e): | |
import traceback | |
with open("/tmp/tb", "w") as f: | |
traceback.print_exc(e, f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bippy(override val toString: String) | |
trait A { implicit def lowPriority: Bippy = new Bippy("A") } | |
object B extends A { implicit def highPriority: Bippy = new Bippy("B") } | |
object C { implicit def highPriority: Bippy = new Bippy("C") } | |
object Test { | |
def main(args: Array[String]): Unit = { | |
import B._, C._ | |
println( implicitly[Bippy] ) // Prints: A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Interact[A] | |
case class Ask(prompt: String) | |
extends Interact[String] | |
case class Tell(msg: String) | |
extends Interact[Unit] | |
trait Monad[M[_]] { | |
def pure[A](a: A): M[A] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quasiquoted excerpt | |
def cdef = q""" | |
class $ClassName[..$classTypeParams](..$primaryParams) extends ..$classParents { | |
..$primaryAccessors | |
def get = this | |
def isEmpty = ${quasi.isEmpty} | |
def copy(..$primaryWithDefaults) = $ObjectName(..$primaryNames) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> import scala.language.experimental.macros | |
import scala.language.experimental.macros | |
scala> import scala.reflect.macros.{ Context, TypecheckException } | |
import scala.reflect.macros.{Context, TypecheckException} | |
scala> object NoncompilationTests { | |
| def compiles(code: _): Boolean = macro compiles_impl | |
| def compiles_impl(c: Context)(code: c.Tree) = c.literal( | |
| try { |
NewerOlder