Skip to content

Instantly share code, notes, and snippets.

Miles Sabin milessabin

Block or report user

Report or block milessabin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@puffnfresh
puffnfresh / Test.scala
Last active Jan 4, 2016
Minimised scalac crash.
View Test.scala
import scalaz._
import Scalaz._
import scalaz.effect._
object Test {
implicit def eitherTMonadIO[M[_], E](implicit M: MonadIO[M]): MonadIO[({type l[A]=EitherT[M, E, A]})#l] = ???
def x = for {
_ <- true whenM IO.putStrLn("World").liftIO[({type e[A]=EitherT[IO, String, A]})#e]
} yield ()
@puffnfresh
puffnfresh / scalaz.sh
Created Dec 20, 2013
Easy scalaz REPL!
View scalaz.sh
# Get yourself sbt-extras
# Or: brew install sbt
alias scalaz="sbt -sbt-create 'set libraryDependencies += \"org.scalaz\" %% \"scalaz-core\" % \"7.1.0-M4\"' 'set initialCommands := \"import scalaz._; import Scalaz._\"' 'console'"
@travisbrown
travisbrown / recursive-vampire.scala
Last active Dec 19, 2015
Tested only in Paradise 2.11.0-SNAPSHOT.
View recursive-vampire.scala
import scala.annotation.StaticAnnotation
import scala.collection.mutable.{ Map => MMap }
import scala.language.experimental.macros
import scala.reflect.macros.Context
class body(tree: Any) extends StaticAnnotation
object Macros {
val trees = MMap.empty[String, c.Tree forSome { val c: Context }]
View gist:5991615
// pseudo-code mixing quasiquotes with 2.10 syntax, don't worry ;)
Macros.doit( "a" -> ("b", "c"), "a1" -> ("b1", "c1") )
object Macros {
def doit(xs: Any*) = macro doitImpl
def doitImpl(c: Context)(xs: c.Expr[Any]*) = {
import c.universe._
val fields = xs.toList map {
@xeno-by
xeno-by / gist:5967900
Created Jul 10, 2013
Macro-powered structural types
View gist:5967900
import scala.annotation.StaticAnnotation
import scala.reflect.macros.Macro
import language.experimental.macros
class body(tree: Any) extends StaticAnnotation
trait Macros extends Macro {
import c.universe._
def selFieldImpl = {
View gist:5965822
import scala.reflect.macros.Context
import language.experimental.macros
object Macros {
def impl1(c: Context) = {
import c.universe._
q"new { def x = macro Macros.impl2 }"
}
def foo = macro impl1
@larsrh
larsrh / sequencer.scala
Last active Dec 16, 2015
Sequence `HList`s
View sequencer.scala
import shapeless._
import scalaz._
import scalaz.syntax.apply._
sealed trait UnapplyFirst[F[_], L <: HList] {
def TC: Applicative[F]
}
@aztek
aztek / FRP.scala
Last active Dec 16, 2015
Trivial FRP for Scala with scala-idioms
View FRP.scala
import idioms._ // http://github.com/aztek/scala-idioms
trait Cell[T] {
def ! : T
def := (value: T) { throw new UnsupportedOperationException }
}
val frp = new Idiom[Cell] {
def pure[A](a: A) = new Cell[A] {
private var value = a
@raichoo
raichoo / gist:5371927
Last active May 12, 2016
Playing with propositional equality in Scala (+inductive proof)
View gist:5371927
import scala.language.higherKinds
/*
* The usual peano numbers with addtion and multiplication
*/
sealed trait Nat {
type Plus[N <: Nat] <: Nat
type Mult[N <: Nat] <: Nat
}
View transcript
scala> class Bippy(xs: List[Int]) extends improving.TypesafeProxy(xs) { def isEmpty = true }
defined class Bippy
scala> val bippy = new Bippy(1 to 10 toList)
bippy: Bippy = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
scala> bippy.slice(3, 7)
[proxy] $line4.$read.$iw.$iw.bippy.slice(3, 7)
res1: List[Int] = List(4, 5, 6, 7)
You can’t perform that action at this time.