Skip to content

Instantly share code, notes, and snippets.

def yipWhenL[I, O, O2](ord: (I, O) => Ordering)(f: (I, Option[O]) => O2): Wye[I, O, O2] = {
val fbL: Tee[I, O, O2] = tee.passL[I] map (f(_, None))
def go(io: Option[I], oo: Option[O]): Wye[I, O, O2] = {
io match {
case None => awaitL[I].flatMap { i => go(Some(i), oo) }
case Some(i) => oo match {
case None => awaitR[O]
.flatMap { o => go(io, Some(o)) }
.orElse { emit(f(i, None)) fby go(None, None) }
case Some(o) => ord(i, o) match {
object Reckeys {
import shapeless.{ HList, HNil, Id }, shapeless.Poly1, shapeless.record.FieldType, shapeless.ops.hlist.{ Mapper, Tupler }, shapeless.syntax.singleton._;
object recordKeys extends Poly1 {
implicit def caseAll[K, V] = at[FieldType[K, V]](ft => ??? : K)
}
def reckeys[L <: HList, P <: HList](ev: L)(implicit m: Mapper.Aux[recordKeys.type, L, P],
t: Tupler[P]): t.type { type Out = t.Out } = t
}
void testSort(UnivInteger len) {
// For Random
val mult = 7**5;
val md = 2**31 - 1;
var ran = Random.start(len, mult, md);
println("Seed = " + len + ", mult = " + mult + ", md = " + md);
type MySorter is Sorting<Vector<UnivInteger>>;
var Vector<UnivInteger> vec = [];
def yipWhenL[I,O,O2](ord: (I,O) => Ordering)(f: (I,Option[O]) => O2): Wye[I,O,O2] = {
val fbL = tee.passL[I] map (f(_,None : Option[O]))
def go(io : Option[I], oo : Option[O]): Wye[I,O,O2] = {
io match {
case None => awaitL[I].flatMap { i => go(Some(i), oo) }
case Some(i) => oo match {
case None => awaitR[O].flatMap(o => go(io,Some(o))) // TODO receiveROr(fbL)...
case Some(o) => ord(i,o) match {
case Ordering.LT => emit(f(i,None)) then go(None,oo)
case Ordering.EQ => emit(f(i,oo)) then go(None,None)
val sql = """select grandparent_id, parent_id, child_id
from children
order by grandparent_id, parent_id, child_id"""
def elementsR[R](invoker: scala.slick.jdbc.Invoker[R]): Process[Task, R] =
resource(Task.delay(invoker.elements()))(
src => Task.delay(src.close)) { src =>
Task.delay { if (src.hasNext) src.next else throw End }
}
import org.json4s._
import org.json4s.native.JsonMethods._
import shapeless._
import poly._
import ops.hlist._
import syntax.singleton._
import record._
object Record {
def keyAsString[F, V](f: FieldType[F, V])(implicit wk: shapeless.Witness.Aux[F]) =
/*
- type mismatch; found : com.tagged.vor.toJSON.type required: ?{def apply(x$1: ? >:
A): ?} Note that implicit conversions are not applicable because they are ambiguous:
both method inst1 in trait PolyInst of type [A](fn: shapeless.Poly)(implicit cse:
fn.ProductCase[shapeless.::[A,shapeless.HNil]])A => cse.Result and macro method apply
in object Poly of type (f: Any)shapeless.Poly are possible conversion functions from
com.tagged.vor.toJSON.type to ?{def apply(x$1: ? >: A): ?}
- Unable to convert expression Expr[Nothing](toJSON) to a polymorphic function
value
*/
object ShapelessTest extends App {
import shapeless._
import record._
import ops.hlist.ToList
import ops.record.{ Keys, Values }
import syntax.singleton._
val ps = List(
("name" ->> "Mel") ::
("age" ->> 90L) ::
@rrmckinley
rrmckinley / index.js
Created October 24, 2014 02:12
requirebin sketch
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("raf")
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
document.body.appendChild(canvas)
var context = canvas.getContext("2d")