Benchmark | Mode | Cnt | Score | Error | Units |
---|---|---|---|---|---|
StreamPressureBench.bench_01_transducers | avgt | 5 | 89.049 | ± 5.785 | ms/op |
StreamPressureBench.bench_01_transducers:·compiler.time.profiled | avgt | 5 | 59.000 | ms | |
StreamPressureBench.bench_01_transducers:·compiler.time.total | avgt | 5 | 938.000 | ms | |
StreamPressureBench.bench_01_transducers:·gc.alloc.rate | avgt | 5 | 3426.787 | ± 224.769 | MB/sec |
StreamPressureBench.bench_01_transducers:·gc.churn.PS_Eden_Space | avgt | 5 | 3422.665 | ± 523.829 | MB/sec |
StreamPressureBench.bench_01_transducers:·gc.churn.PS_Survivor_Space | avgt | 5 | 0.262 | ± 0.485 | MB/sec |
Stream |
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
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Control.Applicative ((<$>), (<*>)) | |
import Control.Monad (mzero) | |
import Data.Aeson | |
import Data.Aeson.Types (emptyObject) | |
import qualified Data.ByteString.Lazy.Char8 as BL |
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
λ> enumFromThenTo 3 9 50 | |
[3,9,15,21,27,33,39,45] | |
it :: (Enum a, Num a) => [a] | |
λ> enumFromThenTo 'A' 'C' 'I' | |
"ACEGI" | |
it :: [Char] | |
λ> data Foo = A | B | C | D | E | F | G | H | I deriving (Enum,Show) | |
λ> enumFromThenTo A C I |
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 Thingy[+A] { | |
def bla(x: String): String | |
val bla2: String ⇒ String = bla | |
} | |
case class Good[A](x: A) extends Thingy[A] { def bla(x: String) = x } | |
case class Bad(t: String) extends Thingy[Nothing] { def bla(x: String) = t } | |
object Thingy { | |
def good1[A](x: A): Thingy[A] = Good(x) |
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
/* | |
* Based on http://stackoverflow.com/a/31641779/2996265 | |
* | |
* Changed: | |
* - use https://github.com/knutwalker/validation to accumulate errors | |
* - support lists as well (polymorphic on higher kinds would be better, though) | |
* - use -Xexperimental for java8 style SAM support | |
*/ | |
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 CreditCard { | |
def charge(price: Double): Unit = | |
println(s"side effect ${##}") | |
} | |
case class Coffee(name: String = "Venti Tall Latte with Grande Soy Frappucino Whip Cream Extra Beans") { | |
def price: Double = 13.37 | |
} |
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 shapeless._ | |
import shapeless.tag._ | |
import shapeless.labelled._ | |
import scala.annotation.implicitNotFound | |
object Pluck { | |
trait FindByName[L <: HList, K] extends DepFn1[L] { | |
type Out |
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 | |
// Run with conscript: http://www.scala-sbt.org/0.13/docs/Scripts.html | |
// Example run: | |
// | |
// $ ./typed-breakage.scala | |
// [state-1]: count = 21776 (should be 10000) | |
// [state-3]: count = 28473 (should be 10000) | |
// [state-2]: count = 29454 (should be 10000) |
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
/** | |
* Demonstrates various possibilities to declare a val and the resulting bytecode. | |
* | |
* Main takeaways are: | |
* - `private[this]` does not generate a getter and genertes direct field access | |
* - compile time constants are `final val x = e` with an optional modifier (§4.1) | |
* - final must be given, even if enclosing class is already final (§ 5.2 - 'final') | |
* - no type annotation may be present | |
*/ | |
final class Main { |
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 shapeless._ | |
import shapeless.labelled._ | |
import shapeless.ops.record._ | |
import scala.annotation.implicitNotFound | |
@implicitNotFound("Cannot prove that ${A} has an 'id: Int' field.") | |
trait HasId[A] { | |
def apply(a: A): Int | |
} |
NewerOlder