Skip to content

Instantly share code, notes, and snippets.

View travisbrown's full-sized avatar
😎
In hiding

Travis Brown travisbrown

😎
In hiding
View GitHub Profile
object test {
trait M[X[_]] {
def map[A, B](a: X[A])(f: A => B): X[B]
}
trait Parsers {
trait Parser[Y] {
def map[B](f: Y => B): Parser[B] = null
}
}
scala> def foo[A, B, C](a: SNat[A], b: SNat[B], c: SNat[C])(implicit ssum: SSum[A, B, C]) = ssum
foo: [A, B, C](a: shapeless.SNat[A], b: shapeless.SNat[B], c: shapeless.SNat[C])(implicit ssum: shapeless.SSum[A,B,C])shapeless.SSum[A,B,C]
scala> foo(2, 3, 5)
res0: shapeless.SSum[Int(2),Int(3),Int(5)] = $anon$1@53d76e96
scala> foo(2, 3, 7)
<console>:15: error: could not find implicit value for parameter ssum: shapeless.SSum[Int(2),Int(3),Int(7)]
foo(2, 3, 7)
^
@travisbrown
travisbrown / Main.scala
Last active December 14, 2015 14:29 — forked from puffnfresh/Main.scala
import MyFuncMacro.myfunc
object MyFuncExample {
def main(args: Array[String]) {
val x: MyFunc[Int, Int] = myfunc { a: Int => a }
println(x)
println(x(42))
}
}
scala> :paste
// Entering paste mode (ctrl-D to finish)
import scala.language.dynamics
import scala.language.experimental.macros
import scala.reflect.macros.whitebox
object implicitly extends Dynamic {
def apply[T](implicit t: T): T {} = t
trait Obs[+A] { def value: A }
object Obs {
import shapeless._, poly._, ops.hlist.Mapper, ops.function.FnToProduct
object values extends (Obs ~> Id) {
def apply[T](t: Obs[T]) = t.value
}
def calculate[T, V <: HList, L <: HList, F, Z](obss: T)(f: F)(implicit
scalaVersion := "2.11.2"
libraryDependencies += "com.chuusai" %% "shapeless" % "2.0.0"
name := "Observe Sample"
package shapeless.stuff
import shapeless._
import nat._
import ops.nat._
import ops.hlist._
/**
* The goal is to determine whether a list of numbers is the appropriate length
* (nine) and has a valid checksum, which is calculated by taking the sum of
// in bijection branch jco/macro_case_class_plus
// ./sbt "bijection-macros/console"
// paste the following
// Use :paste until the break below.
:paste
import com.twitter.bijection._
import com.twitter.bijection.macros.common.TypesNotEqual
trait Semigroup[T] {
sealed trait Key {
type Inner
def inner: Inner
}
trait IntKey extends Key {
type Inner = Int
}
trait StringKey extends Key {
type Inner = String
@travisbrown
travisbrown / README.md
Last active August 29, 2015 14:13 — forked from decretist/README.md

6714256

edF.txt 2192,2194:

    <4 7> -[C. VII.]+ <T R> Ait enim Gregorius I., -[lib. VII. reg. epist. 112.]+
    Siagrio Episcopo Augustodunensi:
    <T T> ...

edF.txt 10695,10697: