This file contains 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 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 () |
This file contains 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
# 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'" |
This file contains 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.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 }] |
This file contains 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
// 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 { |
This file contains 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.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 = { |
This file contains 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.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 |
This file contains 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 shapeless._ | |
import scalaz._ | |
import scalaz.syntax.apply._ | |
sealed trait UnapplyFirst[F[_], L <: HList] { | |
def TC: Applicative[F] | |
} |
This file contains 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 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 |
This file contains 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.language.higherKinds | |
/* | |
* The usual peano numbers with addtion and multiplication | |
*/ | |
sealed trait Nat { | |
type Plus[N <: Nat] <: Nat | |
type Mult[N <: Nat] <: Nat | |
} |
This file contains 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
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) |