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 Foo | |
object Main { | |
def hoge[A](fooCompatible: A)(implicit converter: Converter[A]) = { | |
} | |
def main(args: Array[String]) { | |
hoge(new Foo)(Converter.identity) // この行を消すと下の行もエラーになる | |
hoge(new Foo) | |
} |
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 Foo { | |
def foo { | |
implicitly[Bar](Bar.bar) | |
implicitly[Bar] | |
} | |
} | |
class Bar |
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
import java.sql.ResultSet | |
import java.sql.PreparedStatement | |
import java.sql.Connection | |
import java.sql.Types | |
trait RowParser[A] extends ((ResultSet, Int) => A) { | |
def arity: Int | |
def apply(resultSet: ResultSet, index: Int): 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
# -*- coding: utf-8 -*- | |
class RowParser | |
end | |
class BlockParser < RowParser | |
def initialize(*parsers, &block) | |
@block = block | |
@parsers = parsers | |
end | |
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
import java.util.concurrent.Callable; | |
public class Main { | |
public static void main(String[] args) { | |
Number two1 = new Succ(new Succ(new Zero())); | |
Number two2 = new Succ(new Succ(new Zero())); | |
System.out.println(two1 == two2); | |
System.out.println(two1.myEquals(two2)); | |
} |
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
trait A { | |
type X <: AA | |
trait AA | |
} | |
trait B extends A { | |
type X <: AA with BB | |
trait BB | |
} |
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
require "benchmark" | |
def test(benchmark, pattern, text, run) | |
benchmark.report(text.length.to_s) do | |
run.times do | |
text = text.gsub(pattern, " ") | |
end | |
end | |
end | |
pattern = /[-_.0-9A-Za-z]+@[-_0-9A-Za-z]+[-_.0-9A-Za-z]+/ |
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
import scala.collection.JavaConverters._ | |
object Main extends App { | |
def bench(set1: java.util.Set[Int], set2: java.util.Set[Int]) = { | |
val start = System.nanoTime | |
var sum = 0 | |
0.until(10).map(_ => { | |
val diff = new java.util.HashSet[Int] |
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 Foo { | |
def foo(implicit x: X) = x | |
def foo(implicit y: Y) = y | |
class X | |
class Y | |
implicit val x_ = new X | |
implicit val y_ = new Y | |
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
newtype MyNum a r = MyNum { unNum :: ((MyNum a r -> r) -> r -> r) } | |
zero :: MyNum a r | |
zero = MyNum (\f x -> x) | |
mySucc :: MyNum a r -> MyNum a r | |
mySucc n = MyNum (\f x -> f n) | |
one :: MyNum a r | |
one = mySucc zero |
OlderNewer