Skip to content

Instantly share code, notes, and snippets.

View djspiewak's full-sized avatar

Daniel Spiewak djspiewak

View GitHub Profile
@djspiewak
djspiewak / gist:11334157
Created April 26, 2014 23:49
Scala Typed Logic DSL
trait Unifiable[A] {
???
}
def symbol[A: Unifiable]: Symbol[A] = ???
def pred[A: Unifiable](a: Symbol[A])(f: => Set[Fact]): Predicate1[A] = ???
def pred[A: Unifiable, B: Unifiable](a: Symbol[A], b: Symbol[B])(f: => Set[Fact]): Predicate2[A, B] = ???
lazy val factorial: Predicate2[Int, Int] = {
def ???: Nothing = sys.error("TODO")
scala> val M = implicitly[Monad[Task]]
M: scalaz.Monad[scalaz.concurrent.Task] = scalaz.concurrent.Task$$anon$1@d55df51
scala> var x = 0
x: Int = 0
scala> M point { x += 1 }
res0: scalaz.concurrent.Task[Unit] = scalaz.concurrent.Task@3f4898c5
scala> x
package com.codecommit.misc
import scalaz._
import scalaz.concurrent.Task
import scalaz.iteratee._
import scalaz.stream._
object conversion {
// TODO generalize to EmitterT
unmanagedSourceDirectories in Compile += (sourceDirectory in Compile).value / s"scala-${scalaBinaryVersion.value}",
unmanagedSourceDirectories in Test += (sourceDirectory in Test).value / s"scala-${scalaBinaryVersion.value}"
package com.rr.sinks
package util
import com.typesafe.scalalogging.slf4j.{Logger => SLFLogger}
import org.slf4j.LoggerFactory
import scalaz.concurrent.Task
import scala.reflect.ClassTag
var closure = 1
val generator = Task {
if (closure > 5) {
throw Process.End
}
val back = closure
closure += 1
back
}
object FakeProducts {
implicit def convert2A[A, B](pair: (A, B)): A = pair._1
implicit def convert2B[A, B](pair: (A, B)): B = pair._2
implicit def convert3A[A, B, C](triple: (A, B, C)): A = triple._1
implicit def convert3B[A, B, C](triple: (A, B, C)): B = triple._2
implicit def convert3C[A, B, C](triple: (A, B, C)): C = triple._3
}
package com.rr.sinks
package object util {
/**
* Convenient workaround for soul-sucking exception
* swallowing code like Netty's futures.
*/
def catchLogThrow[A](body: => A): A = {
try {
package com.codecommit.scatter
import scodec._
import scalaz._
import scalaz.stream._
trait Server[Key, Value] {
import Server._