This document is about Task
, an alternative for Scalaz's Task
or Scala's Future
.
Note this is work in progress and this document suffered multiple modifications already:
This file contains hidden or 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
# Note: You MUST have curl 7.47+ with http/2 support compiled in | |
curl -v \ | |
-d '{"aps":{"alert":"<message>","badge":42}}' \ | |
-H "apns-topic: <bundle id>" \ | |
-H "apns-priority: 10" \ | |
--http2 \ | |
--cert <certificate file> \ | |
https://api.development.push.apple.com/3/device/<device token> |
This file contains hidden or 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.JavaConversions._ | |
case class Foo(s: String) | |
val map: Map[Foo, String] = | |
Map( | |
Foo("a") -> "a", | |
Foo("b") -> "b") | |
val v = map.get("a") // should be a type error, actually returns null |
This file contains hidden or 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 bash | |
# | |
# File: kafka-move-leadership.sh | |
# | |
# Description | |
# =========== | |
# | |
# Generates a Kafka partition reassignment JSON snippet to STDOUT to move the leadership | |
# of any replicas away from the provided "source" broker to different, randomly selected | |
# "target" brokers. Run this script with `-h` to show detailed usage instructions. |
This file contains hidden or 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
<b>The source for Scalaz is now hosted on !GitHub - http://github.com/scalaz/scalaz</b> | |
Scalaz is a library written in the [http://scala-lang.org/ Scala Programming Language]. The intention of Scalaz is to include general functions that are not currently available in the core Scala API. The scalaz-core module depends only on [http://www.scala-lang.org/docu/files/api/index.html the core Scala API] and the core Java 2 Standard Edition API. Scalaz is released under a BSD open source licence making it compatible with the licence of the Scala project. | |
[http://code.google.com/p/scalaz/wiki/Scalaz6 Scalaz 6.0.4] was released in January 2012, targeting Scala 2.8.1, 2.9.0.1, 2.9.1 and 2.10.0-M1. [http://scala-tools.org/repo-releases/org/scalaz/scalaz-full_2.9.1/6.0.4/scalaz-full_2.9.1-6.0.4.jar Full download for 2.9.1] | |
[Scalaz7 Scalaz 7] is currently being developed. This is a rewrite to address the challenges posed by type class inheritance. The first release of this series is expected in April 2012. | |
== Community |
This file contains hidden or 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
✘╹◡╹✘ < sbt run | |
[info] Set current project to scala-playground (in build file:/Users/aereal/devel/src/github.com/aereal/scala-playground/) | |
[info] Compiling 1 Scala source to /Users/aereal/devel/src/github.com/aereal/scala-playground/target/scala-2.11/classes... | |
[error] /Users/aereal/devel/src/github.com/aereal/scala-playground/App.scala:7: not found: type ? | |
[error] val v = Applicative[ValidationNel[String, ?]] | |
[error] ^ | |
[error] /Users/aereal/devel/src/github.com/aereal/scala-playground/App.scala:7: scalaz.ValidationNel[String,<error>] takes no type parameters, expected: one | |
[error] val v = Applicative[ValidationNel[String, ?]] | |
[error] ^ | |
[error] /Users/aereal/devel/src/github.com/aereal/scala-playground/App.scala:7: ambiguous implicit values: |
This file contains hidden or 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.atomic.AtomicInteger | |
import java.util.concurrent.{ ThreadFactory, Executors, ExecutorService } | |
import scalaz.concurrent.Task | |
object Test { | |
class MyThreadFactory(prefix: String) extends ThreadFactory { | |
val n = new AtomicInteger(0) | |
override def newThread(r: Runnable) = { | |
val t = Executors.defaultThreadFactory().newThread(r) |
This file contains hidden or 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
package OptionValueAccessor | |
import scala.language.experimental.macros | |
import scala.reflect.macros.whitebox | |
object OptionValueAccessor { | |
implicit def unwrapOptValue[A](a: OptValue[A]): Option[A] = a.unwrap | |
implicit class OptValue[A](val unwrap: Option[A]) extends Dynamic { |
This file contains hidden or 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 Applicative[F[_]] { | |
def pure[A](a: A): F[A] | |
def apply[A, B](f: F[A => B], a: F[A]): F[B] | |
} | |
trait Traversable[T[_], F[_]] { | |
def traverse[A, B](f: A => F[B], a: T[A]): F[T[B]] | |
} | |
trait Monoid[A] { |
This file contains hidden or 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
object TransducerSpecs extends Specification with ScalaCheck { | |
import Process._ | |
import StreamUtils._ | |
"effectful stream transducers" should { | |
def id[I]: Transducer[Nothing, I, I] = | |
transducer.receive1[Nothing, I, I](emit).repeat | |
"perform a simple identity transformation" in prop { xs: List[List[Int]] => | |
val p = emitAll(xs map emitAll).toSource.join |