Skip to content

Instantly share code, notes, and snippets.

@NightRa
NightRa / gist:8284147
Last active January 2, 2016 09:38 — forked from qharlie/gist:8284056
class ModelCombinator extends JavaTokenParsers {
def mod: Parser[Any] = "model" ~ ident ^^ {
case x => println("Hoping for string value of ident " + x.toString())
}
def model: Parser[Any] = "model" ~ ident ~ "{" ~ rep(member) ~ "}"
def member: Parser[Any] = ident ~ ":" ~ ident ~ "@" ~ ("eager" | "lazy") ~ relation.? ~ ";"
@NightRa
NightRa / gist:8924667
Last active August 29, 2015 13:56 — forked from nuttycom/gist:6690987
trait Functor {
type M <: { type T }
def fmap[A, B](fa: M { type T = A })(f: A => B): M { type T = B }
}
implicit class EitherRightFunctor extends Functor { self =>
type L
type M = Either { type A = self.L ; type T = B } //doesn't this specify a subtype of Either, rather than Either itself?
def fmap[A0, B0](fa: M { type A = self.L ; type B = A0 })(f: A0 => B0): Either { type A = self.L ; type B = B0 } =
trait Decorable[A, B] {
def decorate(obj: A, dec: B): Either[String, A]
}
object Decorator {
def decorate[A, B](implicit d: Decorable[A,B]) = d
}
object TagsDecorator {